hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
author shade
Thu, 04 Feb 2016 21:44:23 +0300
changeset 35708 290a3952e434
parent 35135 dd2ce9021031
child 35579 d21d5a0db03f
permissions -rw-r--r--
8149044: jdk/internal/misc/JavaLangAccess/FormatUnsigned.java fails all platforms Summary: Remove the obsolete FormatUnsigned test. Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
     1
/*
29695
7f733c2a8db4 8067891: Remove vestigal G1SATBCT barrier set kind
jprovino
parents: 29183
diff changeset
     2
 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
30225
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
     3
 * Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved.
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
     5
 *
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
     8
 * published by the Free Software Foundation.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
     9
 *
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    14
 * accompanied this code).
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    15
 *
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    19
 *
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    22
 * questions.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    23
 *
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    24
 */
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    25
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    26
#include "precompiled.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    27
#include "asm/macroAssembler.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    28
#include "asm/macroAssembler.inline.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    29
#include "interpreter/interpreter.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    30
#include "nativeInst_aarch64.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    31
#include "oops/instanceOop.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    32
#include "oops/method.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    33
#include "oops/objArrayKlass.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    34
#include "oops/oop.inline.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    35
#include "prims/methodHandles.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    36
#include "runtime/frame.inline.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    37
#include "runtime/handles.inline.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    38
#include "runtime/sharedRuntime.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    39
#include "runtime/stubCodeGenerator.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    40
#include "runtime/stubRoutines.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    41
#include "runtime/thread.inline.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    42
#include "utilities/top.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    43
#ifdef COMPILER2
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    44
#include "opto/runtime.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    45
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    46
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    47
#ifdef BUILTIN_SIM
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    48
#include "../../../../../../simulator/simulator.hpp"
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    49
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    50
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    51
// Declaration and definition of StubGenerator (no .hpp file).
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    52
// For a more detailed description of the stub routine structure
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    53
// see the comment in stubRoutines.hpp
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    54
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    55
#undef __
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    56
#define __ _masm->
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    57
#define TIMES_OOP Address::sxtw(exact_log2(UseCompressedOops ? 4 : 8))
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    58
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    59
#ifdef PRODUCT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    60
#define BLOCK_COMMENT(str) /* nothing */
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    61
#else
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    62
#define BLOCK_COMMENT(str) __ block_comment(str)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    63
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    64
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    65
#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    66
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    67
// Stub Code definitions
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    68
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    69
class StubGenerator: public StubCodeGenerator {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    70
 private:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    71
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    72
#ifdef PRODUCT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    73
#define inc_counter_np(counter) ((void)0)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    74
#else
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    75
  void inc_counter_np_(int& counter) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    76
    __ lea(rscratch2, ExternalAddress((address)&counter));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    77
    __ ldrw(rscratch1, Address(rscratch2));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    78
    __ addw(rscratch1, rscratch1, 1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    79
    __ strw(rscratch1, Address(rscratch2));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    80
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    81
#define inc_counter_np(counter) \
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    82
  BLOCK_COMMENT("inc_counter " #counter); \
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    83
  inc_counter_np_(counter);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    84
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    85
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    86
  // Call stubs are used to call Java from C
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    87
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    88
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    89
  //    c_rarg0:   call wrapper address                   address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    90
  //    c_rarg1:   result                                 address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    91
  //    c_rarg2:   result type                            BasicType
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    92
  //    c_rarg3:   method                                 Method*
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    93
  //    c_rarg4:   (interpreter) entry point              address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    94
  //    c_rarg5:   parameters                             intptr_t*
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    95
  //    c_rarg6:   parameter size (in words)              int
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    96
  //    c_rarg7:   thread                                 Thread*
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    97
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    98
  // There is no return from the stub itself as any Java result
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
    99
  // is written to result
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   100
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   101
  // we save r30 (lr) as the return PC at the base of the frame and
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   102
  // link r29 (fp) below it as the frame pointer installing sp (r31)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   103
  // into fp.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   104
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   105
  // we save r0-r7, which accounts for all the c arguments.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   106
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   107
  // TODO: strictly do we need to save them all? they are treated as
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   108
  // volatile by C so could we omit saving the ones we are going to
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   109
  // place in global registers (thread? method?) or those we only use
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   110
  // during setup of the Java call?
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   111
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   112
  // we don't need to save r8 which C uses as an indirect result location
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   113
  // return register.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   114
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   115
  // we don't need to save r9-r15 which both C and Java treat as
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   116
  // volatile
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   117
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   118
  // we don't need to save r16-18 because Java does not use them
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   119
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   120
  // we save r19-r28 which Java uses as scratch registers and C
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   121
  // expects to be callee-save
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   122
  //
31955
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
   123
  // we save the bottom 64 bits of each value stored in v8-v15; it is
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
   124
  // the responsibility of the caller to preserve larger values.
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   125
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   126
  // so the stub frame looks like this when we enter Java code
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   127
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   128
  //     [ return_from_Java     ] <--- sp
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   129
  //     [ argument word n      ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   130
  //      ...
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   131
  // -27 [ argument word 1      ]
31955
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
   132
  // -26 [ saved v15            ] <--- sp_after_call
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
   133
  // -25 [ saved v14            ]
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
   134
  // -24 [ saved v13            ]
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
   135
  // -23 [ saved v12            ]
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
   136
  // -22 [ saved v11            ]
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
   137
  // -21 [ saved v10            ]
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
   138
  // -20 [ saved v9             ]
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
   139
  // -19 [ saved v8             ]
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   140
  // -18 [ saved r28            ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   141
  // -17 [ saved r27            ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   142
  // -16 [ saved r26            ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   143
  // -15 [ saved r25            ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   144
  // -14 [ saved r24            ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   145
  // -13 [ saved r23            ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   146
  // -12 [ saved r22            ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   147
  // -11 [ saved r21            ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   148
  // -10 [ saved r20            ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   149
  //  -9 [ saved r19            ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   150
  //  -8 [ call wrapper    (r0) ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   151
  //  -7 [ result          (r1) ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   152
  //  -6 [ result type     (r2) ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   153
  //  -5 [ method          (r3) ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   154
  //  -4 [ entry point     (r4) ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   155
  //  -3 [ parameters      (r5) ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   156
  //  -2 [ parameter size  (r6) ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   157
  //  -1 [ thread (r7)          ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   158
  //   0 [ saved fp       (r29) ] <--- fp == saved sp (r31)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   159
  //   1 [ saved lr       (r30) ]
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   160
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   161
  // Call stub stack layout word offsets from fp
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   162
  enum call_stub_layout {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   163
    sp_after_call_off = -26,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   164
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   165
    d15_off            = -26,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   166
    d14_off            = -25,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   167
    d13_off            = -24,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   168
    d12_off            = -23,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   169
    d11_off            = -22,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   170
    d10_off            = -21,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   171
    d9_off             = -20,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   172
    d8_off             = -19,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   173
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   174
    r28_off            = -18,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   175
    r27_off            = -17,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   176
    r26_off            = -16,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   177
    r25_off            = -15,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   178
    r24_off            = -14,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   179
    r23_off            = -13,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   180
    r22_off            = -12,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   181
    r21_off            = -11,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   182
    r20_off            = -10,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   183
    r19_off            =  -9,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   184
    call_wrapper_off   =  -8,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   185
    result_off         =  -7,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   186
    result_type_off    =  -6,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   187
    method_off         =  -5,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   188
    entry_point_off    =  -4,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   189
    parameters_off     =  -3,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   190
    parameter_size_off =  -2,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   191
    thread_off         =  -1,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   192
    fp_f               =   0,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   193
    retaddr_off        =   1,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   194
  };
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   195
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   196
  address generate_call_stub(address& return_address) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   197
    assert((int)frame::entry_frame_after_call_words == -(int)sp_after_call_off + 1 &&
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   198
           (int)frame::entry_frame_call_wrapper_offset == (int)call_wrapper_off,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   199
           "adjust this code");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   200
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   201
    StubCodeMark mark(this, "StubRoutines", "call_stub");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   202
    address start = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   203
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   204
    const Address sp_after_call(rfp, sp_after_call_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   205
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   206
    const Address call_wrapper  (rfp, call_wrapper_off   * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   207
    const Address result        (rfp, result_off         * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   208
    const Address result_type   (rfp, result_type_off    * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   209
    const Address method        (rfp, method_off         * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   210
    const Address entry_point   (rfp, entry_point_off    * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   211
    const Address parameters    (rfp, parameters_off     * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   212
    const Address parameter_size(rfp, parameter_size_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   213
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   214
    const Address thread        (rfp, thread_off         * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   215
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   216
    const Address d15_save      (rfp, d15_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   217
    const Address d14_save      (rfp, d14_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   218
    const Address d13_save      (rfp, d13_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   219
    const Address d12_save      (rfp, d12_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   220
    const Address d11_save      (rfp, d11_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   221
    const Address d10_save      (rfp, d10_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   222
    const Address d9_save       (rfp, d9_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   223
    const Address d8_save       (rfp, d8_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   224
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   225
    const Address r28_save      (rfp, r28_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   226
    const Address r27_save      (rfp, r27_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   227
    const Address r26_save      (rfp, r26_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   228
    const Address r25_save      (rfp, r25_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   229
    const Address r24_save      (rfp, r24_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   230
    const Address r23_save      (rfp, r23_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   231
    const Address r22_save      (rfp, r22_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   232
    const Address r21_save      (rfp, r21_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   233
    const Address r20_save      (rfp, r20_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   234
    const Address r19_save      (rfp, r19_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   235
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   236
    // stub code
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   237
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   238
    // we need a C prolog to bootstrap the x86 caller into the sim
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   239
    __ c_stub_prolog(8, 0, MacroAssembler::ret_type_void);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   240
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   241
    address aarch64_entry = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   242
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   243
#ifdef BUILTIN_SIM
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   244
    // Save sender's SP for stack traces.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   245
    __ mov(rscratch1, sp);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   246
    __ str(rscratch1, Address(__ pre(sp, -2 * wordSize)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   247
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   248
    // set up frame and move sp to end of save area
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   249
    __ enter();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   250
    __ sub(sp, rfp, -sp_after_call_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   251
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   252
    // save register parameters and Java scratch/global registers
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   253
    // n.b. we save thread even though it gets installed in
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   254
    // rthread because we want to sanity check rthread later
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   255
    __ str(c_rarg7,  thread);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   256
    __ strw(c_rarg6, parameter_size);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   257
    __ str(c_rarg5,  parameters);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   258
    __ str(c_rarg4,  entry_point);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   259
    __ str(c_rarg3,  method);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   260
    __ str(c_rarg2,  result_type);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   261
    __ str(c_rarg1,  result);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   262
    __ str(c_rarg0,  call_wrapper);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   263
    __ str(r19,      r19_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   264
    __ str(r20,      r20_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   265
    __ str(r21,      r21_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   266
    __ str(r22,      r22_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   267
    __ str(r23,      r23_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   268
    __ str(r24,      r24_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   269
    __ str(r25,      r25_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   270
    __ str(r26,      r26_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   271
    __ str(r27,      r27_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   272
    __ str(r28,      r28_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   273
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   274
    __ strd(v8,      d8_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   275
    __ strd(v9,      d9_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   276
    __ strd(v10,     d10_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   277
    __ strd(v11,     d11_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   278
    __ strd(v12,     d12_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   279
    __ strd(v13,     d13_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   280
    __ strd(v14,     d14_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   281
    __ strd(v15,     d15_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   282
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   283
    // install Java thread in global register now we have saved
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   284
    // whatever value it held
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   285
    __ mov(rthread, c_rarg7);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   286
    // And method
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   287
    __ mov(rmethod, c_rarg3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   288
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   289
    // set up the heapbase register
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   290
    __ reinit_heapbase();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   291
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   292
#ifdef ASSERT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   293
    // make sure we have no pending exceptions
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   294
    {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   295
      Label L;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   296
      __ ldr(rscratch1, Address(rthread, in_bytes(Thread::pending_exception_offset())));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   297
      __ cmp(rscratch1, (unsigned)NULL_WORD);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   298
      __ br(Assembler::EQ, L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   299
      __ stop("StubRoutines::call_stub: entered with pending exception");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   300
      __ BIND(L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   301
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   302
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   303
    // pass parameters if any
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   304
    __ mov(esp, sp);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   305
    __ sub(rscratch1, sp, c_rarg6, ext::uxtw, LogBytesPerWord); // Move SP out of the way
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   306
    __ andr(sp, rscratch1, -2 * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   307
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   308
    BLOCK_COMMENT("pass parameters if any");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   309
    Label parameters_done;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   310
    // parameter count is still in c_rarg6
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   311
    // and parameter pointer identifying param 1 is in c_rarg5
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   312
    __ cbzw(c_rarg6, parameters_done);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   313
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   314
    address loop = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   315
    __ ldr(rscratch1, Address(__ post(c_rarg5, wordSize)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   316
    __ subsw(c_rarg6, c_rarg6, 1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   317
    __ push(rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   318
    __ br(Assembler::GT, loop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   319
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   320
    __ BIND(parameters_done);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   321
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   322
    // call Java entry -- passing methdoOop, and current sp
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   323
    //      rmethod: Method*
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   324
    //      r13: sender sp
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   325
    BLOCK_COMMENT("call Java function");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   326
    __ mov(r13, sp);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   327
    __ blr(c_rarg4);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   328
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   329
    // tell the simulator we have returned to the stub
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   330
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   331
    // we do this here because the notify will already have been done
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   332
    // if we get to the next instruction via an exception
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   333
    //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   334
    // n.b. adding this instruction here affects the calculation of
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   335
    // whether or not a routine returns to the call stub (used when
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   336
    // doing stack walks) since the normal test is to check the return
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   337
    // pc against the address saved below. so we may need to allow for
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   338
    // this extra instruction in the check.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   339
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   340
    if (NotifySimulator) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   341
      __ notify(Assembler::method_reentry);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   342
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   343
    // save current address for use by exception handling code
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   344
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   345
    return_address = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   346
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   347
    // store result depending on type (everything that is not
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   348
    // T_OBJECT, T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   349
    // n.b. this assumes Java returns an integral result in r0
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   350
    // and a floating result in j_farg0
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   351
    __ ldr(j_rarg2, result);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   352
    Label is_long, is_float, is_double, exit;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   353
    __ ldr(j_rarg1, result_type);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   354
    __ cmp(j_rarg1, T_OBJECT);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   355
    __ br(Assembler::EQ, is_long);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   356
    __ cmp(j_rarg1, T_LONG);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   357
    __ br(Assembler::EQ, is_long);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   358
    __ cmp(j_rarg1, T_FLOAT);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   359
    __ br(Assembler::EQ, is_float);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   360
    __ cmp(j_rarg1, T_DOUBLE);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   361
    __ br(Assembler::EQ, is_double);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   362
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   363
    // handle T_INT case
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   364
    __ strw(r0, Address(j_rarg2));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   365
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   366
    __ BIND(exit);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   367
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   368
    // pop parameters
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   369
    __ sub(esp, rfp, -sp_after_call_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   370
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   371
#ifdef ASSERT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   372
    // verify that threads correspond
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   373
    {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   374
      Label L, S;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   375
      __ ldr(rscratch1, thread);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   376
      __ cmp(rthread, rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   377
      __ br(Assembler::NE, S);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   378
      __ get_thread(rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   379
      __ cmp(rthread, rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   380
      __ br(Assembler::EQ, L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   381
      __ BIND(S);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   382
      __ stop("StubRoutines::call_stub: threads must correspond");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   383
      __ BIND(L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   384
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   385
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   386
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   387
    // restore callee-save registers
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   388
    __ ldrd(v15,      d15_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   389
    __ ldrd(v14,      d14_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   390
    __ ldrd(v13,      d13_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   391
    __ ldrd(v12,      d12_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   392
    __ ldrd(v11,      d11_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   393
    __ ldrd(v10,      d10_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   394
    __ ldrd(v9,       d9_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   395
    __ ldrd(v8,       d8_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   396
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   397
    __ ldr(r28,      r28_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   398
    __ ldr(r27,      r27_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   399
    __ ldr(r26,      r26_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   400
    __ ldr(r25,      r25_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   401
    __ ldr(r24,      r24_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   402
    __ ldr(r23,      r23_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   403
    __ ldr(r22,      r22_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   404
    __ ldr(r21,      r21_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   405
    __ ldr(r20,      r20_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   406
    __ ldr(r19,      r19_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   407
    __ ldr(c_rarg0,  call_wrapper);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   408
    __ ldr(c_rarg1,  result);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   409
    __ ldrw(c_rarg2, result_type);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   410
    __ ldr(c_rarg3,  method);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   411
    __ ldr(c_rarg4,  entry_point);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   412
    __ ldr(c_rarg5,  parameters);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   413
    __ ldr(c_rarg6,  parameter_size);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   414
    __ ldr(c_rarg7,  thread);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   415
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   416
#ifndef PRODUCT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   417
    // tell the simulator we are about to end Java execution
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   418
    if (NotifySimulator) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   419
      __ notify(Assembler::method_exit);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   420
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   421
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   422
    // leave frame and return to caller
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   423
    __ leave();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   424
    __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   425
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   426
    // handle return types different from T_INT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   427
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   428
    __ BIND(is_long);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   429
    __ str(r0, Address(j_rarg2, 0));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   430
    __ br(Assembler::AL, exit);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   431
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   432
    __ BIND(is_float);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   433
    __ strs(j_farg0, Address(j_rarg2, 0));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   434
    __ br(Assembler::AL, exit);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   435
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   436
    __ BIND(is_double);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   437
    __ strd(j_farg0, Address(j_rarg2, 0));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   438
    __ br(Assembler::AL, exit);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   439
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   440
    return start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   441
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   442
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   443
  // Return point for a Java call if there's an exception thrown in
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   444
  // Java code.  The exception is caught and transformed into a
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   445
  // pending exception stored in JavaThread that can be tested from
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   446
  // within the VM.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   447
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   448
  // Note: Usually the parameters are removed by the callee. In case
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   449
  // of an exception crossing an activation frame boundary, that is
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   450
  // not the case if the callee is compiled code => need to setup the
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   451
  // rsp.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   452
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   453
  // r0: exception oop
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   454
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   455
  // NOTE: this is used as a target from the signal handler so it
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   456
  // needs an x86 prolog which returns into the current simulator
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   457
  // executing the generated catch_exception code. so the prolog
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   458
  // needs to install rax in a sim register and adjust the sim's
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   459
  // restart pc to enter the generated code at the start position
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   460
  // then return from native to simulated execution.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   461
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   462
  address generate_catch_exception() {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   463
    StubCodeMark mark(this, "StubRoutines", "catch_exception");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   464
    address start = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   465
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   466
    // same as in generate_call_stub():
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   467
    const Address sp_after_call(rfp, sp_after_call_off * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   468
    const Address thread        (rfp, thread_off         * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   469
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   470
#ifdef ASSERT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   471
    // verify that threads correspond
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   472
    {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   473
      Label L, S;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   474
      __ ldr(rscratch1, thread);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   475
      __ cmp(rthread, rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   476
      __ br(Assembler::NE, S);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   477
      __ get_thread(rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   478
      __ cmp(rthread, rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   479
      __ br(Assembler::EQ, L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   480
      __ bind(S);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   481
      __ stop("StubRoutines::catch_exception: threads must correspond");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   482
      __ bind(L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   483
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   484
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   485
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   486
    // set pending exception
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   487
    __ verify_oop(r0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   488
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   489
    __ str(r0, Address(rthread, Thread::pending_exception_offset()));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   490
    __ mov(rscratch1, (address)__FILE__);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   491
    __ str(rscratch1, Address(rthread, Thread::exception_file_offset()));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   492
    __ movw(rscratch1, (int)__LINE__);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   493
    __ strw(rscratch1, Address(rthread, Thread::exception_line_offset()));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   494
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   495
    // complete return to VM
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   496
    assert(StubRoutines::_call_stub_return_address != NULL,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   497
           "_call_stub_return_address must have been generated before");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   498
    __ b(StubRoutines::_call_stub_return_address);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   499
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   500
    return start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   501
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   502
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   503
  // Continuation point for runtime calls returning with a pending
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   504
  // exception.  The pending exception check happened in the runtime
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   505
  // or native call stub.  The pending exception in Thread is
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   506
  // converted into a Java-level exception.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   507
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   508
  // Contract with Java-level exception handlers:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   509
  // r0: exception
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   510
  // r3: throwing pc
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   511
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   512
  // NOTE: At entry of this stub, exception-pc must be in LR !!
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   513
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   514
  // NOTE: this is always used as a jump target within generated code
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   515
  // so it just needs to be generated code wiht no x86 prolog
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   516
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   517
  address generate_forward_exception() {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   518
    StubCodeMark mark(this, "StubRoutines", "forward exception");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   519
    address start = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   520
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   521
    // Upon entry, LR points to the return address returning into
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   522
    // Java (interpreted or compiled) code; i.e., the return address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   523
    // becomes the throwing pc.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   524
    //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   525
    // Arguments pushed before the runtime call are still on the stack
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   526
    // but the exception handler will reset the stack pointer ->
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   527
    // ignore them.  A potential result in registers can be ignored as
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   528
    // well.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   529
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   530
#ifdef ASSERT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   531
    // make sure this code is only executed if there is a pending exception
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   532
    {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   533
      Label L;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   534
      __ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset()));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   535
      __ cbnz(rscratch1, L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   536
      __ stop("StubRoutines::forward exception: no pending exception (1)");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   537
      __ bind(L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   538
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   539
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   540
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   541
    // compute exception handler into r19
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   542
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   543
    // call the VM to find the handler address associated with the
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   544
    // caller address. pass thread in r0 and caller pc (ret address)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   545
    // in r1. n.b. the caller pc is in lr, unlike x86 where it is on
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   546
    // the stack.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   547
    __ mov(c_rarg1, lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   548
    // lr will be trashed by the VM call so we move it to R19
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   549
    // (callee-saved) because we also need to pass it to the handler
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   550
    // returned by this call.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   551
    __ mov(r19, lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   552
    BLOCK_COMMENT("call exception_handler_for_return_address");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   553
    __ call_VM_leaf(CAST_FROM_FN_PTR(address,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   554
                         SharedRuntime::exception_handler_for_return_address),
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   555
                    rthread, c_rarg1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   556
    // we should not really care that lr is no longer the callee
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   557
    // address. we saved the value the handler needs in r19 so we can
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   558
    // just copy it to r3. however, the C2 handler will push its own
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   559
    // frame and then calls into the VM and the VM code asserts that
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   560
    // the PC for the frame above the handler belongs to a compiled
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   561
    // Java method. So, we restore lr here to satisfy that assert.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   562
    __ mov(lr, r19);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   563
    // setup r0 & r3 & clear pending exception
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   564
    __ mov(r3, r19);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   565
    __ mov(r19, r0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   566
    __ ldr(r0, Address(rthread, Thread::pending_exception_offset()));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   567
    __ str(zr, Address(rthread, Thread::pending_exception_offset()));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   568
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   569
#ifdef ASSERT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   570
    // make sure exception is set
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   571
    {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   572
      Label L;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   573
      __ cbnz(r0, L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   574
      __ stop("StubRoutines::forward exception: no pending exception (2)");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   575
      __ bind(L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   576
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   577
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   578
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   579
    // continue at exception handler
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   580
    // r0: exception
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   581
    // r3: throwing pc
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   582
    // r19: exception handler
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   583
    __ verify_oop(r0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   584
    __ br(r19);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   585
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   586
    return start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   587
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   588
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   589
  // Non-destructive plausibility checks for oops
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   590
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   591
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   592
  //    r0: oop to verify
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   593
  //    rscratch1: error message
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   594
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   595
  // Stack after saving c_rarg3:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   596
  //    [tos + 0]: saved c_rarg3
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   597
  //    [tos + 1]: saved c_rarg2
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   598
  //    [tos + 2]: saved lr
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   599
  //    [tos + 3]: saved rscratch2
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   600
  //    [tos + 4]: saved r0
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   601
  //    [tos + 5]: saved rscratch1
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   602
  address generate_verify_oop() {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   603
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   604
    StubCodeMark mark(this, "StubRoutines", "verify_oop");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   605
    address start = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   606
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   607
    Label exit, error;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   608
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   609
    // save c_rarg2 and c_rarg3
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   610
    __ stp(c_rarg3, c_rarg2, Address(__ pre(sp, -16)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   611
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   612
    // __ incrementl(ExternalAddress((address) StubRoutines::verify_oop_count_addr()));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   613
    __ lea(c_rarg2, ExternalAddress((address) StubRoutines::verify_oop_count_addr()));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   614
    __ ldr(c_rarg3, Address(c_rarg2));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   615
    __ add(c_rarg3, c_rarg3, 1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   616
    __ str(c_rarg3, Address(c_rarg2));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   617
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   618
    // object is in r0
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   619
    // make sure object is 'reasonable'
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   620
    __ cbz(r0, exit); // if obj is NULL it is OK
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   621
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   622
    // Check if the oop is in the right area of memory
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   623
    __ mov(c_rarg3, (intptr_t) Universe::verify_oop_mask());
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   624
    __ andr(c_rarg2, r0, c_rarg3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   625
    __ mov(c_rarg3, (intptr_t) Universe::verify_oop_bits());
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   626
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   627
    // Compare c_rarg2 and c_rarg3.  We don't use a compare
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   628
    // instruction here because the flags register is live.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   629
    __ eor(c_rarg2, c_rarg2, c_rarg3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   630
    __ cbnz(c_rarg2, error);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   631
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   632
    // make sure klass is 'reasonable', which is not zero.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   633
    __ load_klass(r0, r0);  // get klass
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   634
    __ cbz(r0, error);      // if klass is NULL it is broken
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   635
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   636
    // return if everything seems ok
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   637
    __ bind(exit);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   638
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   639
    __ ldp(c_rarg3, c_rarg2, Address(__ post(sp, 16)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   640
    __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   641
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   642
    // handle errors
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   643
    __ bind(error);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   644
    __ ldp(c_rarg3, c_rarg2, Address(__ post(sp, 16)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   645
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   646
    __ push(RegSet::range(r0, r29), sp);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   647
    // debug(char* msg, int64_t pc, int64_t regs[])
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   648
    __ mov(c_rarg0, rscratch1);      // pass address of error message
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   649
    __ mov(c_rarg1, lr);             // pass return address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   650
    __ mov(c_rarg2, sp);             // pass address of regs on stack
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   651
#ifndef PRODUCT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   652
    assert(frame::arg_reg_save_area_bytes == 0, "not expecting frame reg save area");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   653
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   654
    BLOCK_COMMENT("call MacroAssembler::debug");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   655
    __ mov(rscratch1, CAST_FROM_FN_PTR(address, MacroAssembler::debug64));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   656
    __ blrt(rscratch1, 3, 0, 1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   657
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   658
    return start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   659
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   660
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   661
  void array_overlap_test(Label& L_no_overlap, Address::sxtw sf) { __ b(L_no_overlap); }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   662
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   663
  // Generate code for an array write pre barrier
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   664
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   665
  //     addr    -  starting address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   666
  //     count   -  element count
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   667
  //     tmp     - scratch register
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   668
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   669
  //     Destroy no registers!
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   670
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   671
  void  gen_write_ref_array_pre_barrier(Register addr, Register count, bool dest_uninitialized) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   672
    BarrierSet* bs = Universe::heap()->barrier_set();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   673
    switch (bs->kind()) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   674
    case BarrierSet::G1SATBCTLogging:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   675
      // With G1, don't generate the call if we statically know that the target in uninitialized
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   676
      if (!dest_uninitialized) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   677
        __ push(RegSet::range(r0, r29), sp);         // integer registers except lr & sp
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   678
        if (count == c_rarg0) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   679
          if (addr == c_rarg1) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   680
            // exactly backwards!!
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   681
            __ stp(c_rarg0, c_rarg1, __ pre(sp, -2 * wordSize));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   682
            __ ldp(c_rarg1, c_rarg0, __ post(sp, -2 * wordSize));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   683
          } else {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   684
            __ mov(c_rarg1, count);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   685
            __ mov(c_rarg0, addr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   686
          }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   687
        } else {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   688
          __ mov(c_rarg0, addr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   689
          __ mov(c_rarg1, count);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   690
        }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   691
        __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_pre), 2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   692
        __ pop(RegSet::range(r0, r29), sp);         // integer registers except lr & sp        }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   693
        break;
32596
8feecdee3156 8072817: CardTableExtension kind() should be BarrierSet::CardTableExtension
kbarrett
parents: 31961
diff changeset
   694
      case BarrierSet::CardTableForRS:
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   695
      case BarrierSet::CardTableExtension:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   696
      case BarrierSet::ModRef:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   697
        break;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   698
      default:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   699
        ShouldNotReachHere();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   700
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   701
      }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   702
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   703
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   704
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   705
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   706
  // Generate code for an array write post barrier
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   707
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   708
  //  Input:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   709
  //     start    - register containing starting address of destination array
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   710
  //     end      - register containing ending address of destination array
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   711
  //     scratch  - scratch register
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   712
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   713
  //  The input registers are overwritten.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   714
  //  The ending address is inclusive.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   715
  void gen_write_ref_array_post_barrier(Register start, Register end, Register scratch) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   716
    assert_different_registers(start, end, scratch);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   717
    BarrierSet* bs = Universe::heap()->barrier_set();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   718
    switch (bs->kind()) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   719
      case BarrierSet::G1SATBCTLogging:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   720
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   721
        {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   722
          __ push(RegSet::range(r0, r29), sp);         // integer registers except lr & sp
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   723
          // must compute element count unless barrier set interface is changed (other platforms supply count)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   724
          assert_different_registers(start, end, scratch);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   725
          __ lea(scratch, Address(end, BytesPerHeapOop));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   726
          __ sub(scratch, scratch, start);               // subtract start to get #bytes
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   727
          __ lsr(scratch, scratch, LogBytesPerHeapOop);  // convert to element count
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   728
          __ mov(c_rarg0, start);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   729
          __ mov(c_rarg1, scratch);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   730
          __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_post), 2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   731
          __ pop(RegSet::range(r0, r29), sp);         // integer registers except lr & sp        }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   732
        }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   733
        break;
32596
8feecdee3156 8072817: CardTableExtension kind() should be BarrierSet::CardTableExtension
kbarrett
parents: 31961
diff changeset
   734
      case BarrierSet::CardTableForRS:
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   735
      case BarrierSet::CardTableExtension:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   736
        {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   737
          CardTableModRefBS* ct = (CardTableModRefBS*)bs;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   738
          assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   739
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   740
          Label L_loop;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   741
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   742
           __ lsr(start, start, CardTableModRefBS::card_shift);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   743
           __ lsr(end, end, CardTableModRefBS::card_shift);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   744
           __ sub(end, end, start); // number of bytes to copy
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   745
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   746
          const Register count = end; // 'end' register contains bytes count now
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   747
          __ mov(scratch, (address)ct->byte_map_base);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   748
          __ add(start, start, scratch);
33096
d38227d62ef4 8135018: AARCH64: Missing memory barriers for CMS collector
aph
parents: 32627
diff changeset
   749
          if (UseConcMarkSweepGC) {
d38227d62ef4 8135018: AARCH64: Missing memory barriers for CMS collector
aph
parents: 32627
diff changeset
   750
            __ membar(__ StoreStore);
d38227d62ef4 8135018: AARCH64: Missing memory barriers for CMS collector
aph
parents: 32627
diff changeset
   751
          }
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   752
          __ BIND(L_loop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   753
          __ strb(zr, Address(start, count));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   754
          __ subs(count, count, 1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   755
          __ br(Assembler::HS, L_loop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   756
        }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   757
        break;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   758
      default:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   759
        ShouldNotReachHere();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   760
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   761
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   762
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   763
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   764
  typedef enum {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   765
    copy_forwards = 1,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   766
    copy_backwards = -1
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   767
  } copy_direction;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   768
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   769
  // Bulk copy of blocks of 8 words.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   770
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   771
  // count is a count of words.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   772
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   773
  // Precondition: count >= 2
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   774
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   775
  // Postconditions:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   776
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   777
  // The least significant bit of count contains the remaining count
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   778
  // of words to copy.  The rest of count is trash.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   779
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   780
  // s and d are adjusted to point to the remaining words to copy
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   781
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   782
  void generate_copy_longs(Label &start, Register s, Register d, Register count,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   783
                           copy_direction direction) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   784
    int unit = wordSize * direction;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   785
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   786
    int offset;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   787
    const Register t0 = r3, t1 = r4, t2 = r5, t3 = r6,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   788
      t4 = r7, t5 = r10, t6 = r11, t7 = r12;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   789
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   790
    assert_different_registers(rscratch1, t0, t1, t2, t3, t4, t5, t6, t7);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   791
    assert_different_registers(s, d, count, rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   792
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   793
    Label again, large, small;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   794
    __ align(6);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   795
    __ bind(start);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   796
    __ cmp(count, 8);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   797
    __ br(Assembler::LO, small);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   798
    if (direction == copy_forwards) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   799
      __ sub(s, s, 2 * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   800
      __ sub(d, d, 2 * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   801
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   802
    __ subs(count, count, 16);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   803
    __ br(Assembler::GE, large);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   804
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   805
    // 8 <= count < 16 words.  Copy 8.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   806
    __ ldp(t0, t1, Address(s, 2 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   807
    __ ldp(t2, t3, Address(s, 4 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   808
    __ ldp(t4, t5, Address(s, 6 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   809
    __ ldp(t6, t7, Address(__ pre(s, 8 * unit)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   810
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   811
    __ stp(t0, t1, Address(d, 2 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   812
    __ stp(t2, t3, Address(d, 4 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   813
    __ stp(t4, t5, Address(d, 6 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   814
    __ stp(t6, t7, Address(__ pre(d, 8 * unit)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   815
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   816
    if (direction == copy_forwards) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   817
      __ add(s, s, 2 * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   818
      __ add(d, d, 2 * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   819
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   820
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   821
    {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   822
      Label L1, L2;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   823
      __ bind(small);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   824
      __ tbz(count, exact_log2(4), L1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   825
      __ ldp(t0, t1, Address(__ adjust(s, 2 * unit, direction == copy_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   826
      __ ldp(t2, t3, Address(__ adjust(s, 2 * unit, direction == copy_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   827
      __ stp(t0, t1, Address(__ adjust(d, 2 * unit, direction == copy_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   828
      __ stp(t2, t3, Address(__ adjust(d, 2 * unit, direction == copy_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   829
      __ bind(L1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   830
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   831
      __ tbz(count, 1, L2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   832
      __ ldp(t0, t1, Address(__ adjust(s, 2 * unit, direction == copy_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   833
      __ stp(t0, t1, Address(__ adjust(d, 2 * unit, direction == copy_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   834
      __ bind(L2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   835
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   836
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   837
    __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   838
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   839
    __ align(6);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   840
    __ bind(large);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   841
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   842
    // Fill 8 registers
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   843
    __ ldp(t0, t1, Address(s, 2 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   844
    __ ldp(t2, t3, Address(s, 4 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   845
    __ ldp(t4, t5, Address(s, 6 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   846
    __ ldp(t6, t7, Address(__ pre(s, 8 * unit)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   847
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   848
    __ bind(again);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   849
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   850
    if (direction == copy_forwards && PrefetchCopyIntervalInBytes > 0)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   851
      __ prfm(Address(s, PrefetchCopyIntervalInBytes), PLDL1KEEP);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   852
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   853
    __ stp(t0, t1, Address(d, 2 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   854
    __ ldp(t0, t1, Address(s, 2 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   855
    __ stp(t2, t3, Address(d, 4 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   856
    __ ldp(t2, t3, Address(s, 4 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   857
    __ stp(t4, t5, Address(d, 6 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   858
    __ ldp(t4, t5, Address(s, 6 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   859
    __ stp(t6, t7, Address(__ pre(d, 8 * unit)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   860
    __ ldp(t6, t7, Address(__ pre(s, 8 * unit)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   861
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   862
    __ subs(count, count, 8);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   863
    __ br(Assembler::HS, again);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   864
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   865
    // Drain
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   866
    __ stp(t0, t1, Address(d, 2 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   867
    __ stp(t2, t3, Address(d, 4 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   868
    __ stp(t4, t5, Address(d, 6 * unit));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   869
    __ stp(t6, t7, Address(__ pre(d, 8 * unit)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   870
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   871
    if (direction == copy_forwards) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   872
      __ add(s, s, 2 * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   873
      __ add(d, d, 2 * wordSize);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   874
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   875
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   876
    {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   877
      Label L1, L2;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   878
      __ tbz(count, exact_log2(4), L1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   879
      __ ldp(t0, t1, Address(__ adjust(s, 2 * unit, direction == copy_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   880
      __ ldp(t2, t3, Address(__ adjust(s, 2 * unit, direction == copy_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   881
      __ stp(t0, t1, Address(__ adjust(d, 2 * unit, direction == copy_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   882
      __ stp(t2, t3, Address(__ adjust(d, 2 * unit, direction == copy_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   883
      __ bind(L1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   884
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   885
      __ tbz(count, 1, L2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   886
      __ ldp(t0, t1, Address(__ adjust(s, 2 * unit, direction == copy_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   887
      __ stp(t0, t1, Address(__ adjust(d, 2 * unit, direction == copy_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   888
      __ bind(L2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   889
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   890
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   891
    __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   892
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   893
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   894
  // Small copy: less than 16 bytes.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   895
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   896
  // NB: Ignores all of the bits of count which represent more than 15
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   897
  // bytes, so a caller doesn't have to mask them.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   898
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   899
  void copy_memory_small(Register s, Register d, Register count, Register tmp, int step) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   900
    bool is_backwards = step < 0;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   901
    size_t granularity = uabs(step);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   902
    int direction = is_backwards ? -1 : 1;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   903
    int unit = wordSize * direction;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   904
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   905
    Label Lpair, Lword, Lint, Lshort, Lbyte;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   906
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   907
    assert(granularity
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   908
           && granularity <= sizeof (jlong), "Impossible granularity in copy_memory_small");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   909
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   910
    const Register t0 = r3, t1 = r4, t2 = r5, t3 = r6;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   911
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   912
    // ??? I don't know if this bit-test-and-branch is the right thing
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   913
    // to do.  It does a lot of jumping, resulting in several
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   914
    // mispredicted branches.  It might make more sense to do this
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   915
    // with something like Duff's device with a single computed branch.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   916
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   917
    __ tbz(count, 3 - exact_log2(granularity), Lword);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   918
    __ ldr(tmp, Address(__ adjust(s, unit, is_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   919
    __ str(tmp, Address(__ adjust(d, unit, is_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   920
    __ bind(Lword);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   921
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   922
    if (granularity <= sizeof (jint)) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   923
      __ tbz(count, 2 - exact_log2(granularity), Lint);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   924
      __ ldrw(tmp, Address(__ adjust(s, sizeof (jint) * direction, is_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   925
      __ strw(tmp, Address(__ adjust(d, sizeof (jint) * direction, is_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   926
      __ bind(Lint);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   927
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   928
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   929
    if (granularity <= sizeof (jshort)) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   930
      __ tbz(count, 1 - exact_log2(granularity), Lshort);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   931
      __ ldrh(tmp, Address(__ adjust(s, sizeof (jshort) * direction, is_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   932
      __ strh(tmp, Address(__ adjust(d, sizeof (jshort) * direction, is_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   933
      __ bind(Lshort);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   934
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   935
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   936
    if (granularity <= sizeof (jbyte)) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   937
      __ tbz(count, 0, Lbyte);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   938
      __ ldrb(tmp, Address(__ adjust(s, sizeof (jbyte) * direction, is_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   939
      __ strb(tmp, Address(__ adjust(d, sizeof (jbyte) * direction, is_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   940
      __ bind(Lbyte);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   941
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   942
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   943
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   944
  Label copy_f, copy_b;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   945
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   946
  // All-singing all-dancing memory copy.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   947
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   948
  // Copy count units of memory from s to d.  The size of a unit is
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   949
  // step, which can be positive or negative depending on the direction
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   950
  // of copy.  If is_aligned is false, we align the source address.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   951
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   952
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   953
  void copy_memory(bool is_aligned, Register s, Register d,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   954
                   Register count, Register tmp, int step) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   955
    copy_direction direction = step < 0 ? copy_backwards : copy_forwards;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   956
    bool is_backwards = step < 0;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   957
    int granularity = uabs(step);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   958
    const Register t0 = r3, t1 = r4;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   959
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   960
    if (is_backwards) {
35119
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
   961
      __ lea(s, Address(s, count, Address::lsl(exact_log2(-step))));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
   962
      __ lea(d, Address(d, count, Address::lsl(exact_log2(-step))));
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   963
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   964
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   965
    Label done, tail;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   966
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   967
    __ cmp(count, 16/granularity);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   968
    __ br(Assembler::LO, tail);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   969
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   970
    // Now we've got the small case out of the way we can align the
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   971
    // source address on a 2-word boundary.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   972
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   973
    Label aligned;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   974
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   975
    if (is_aligned) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   976
      // We may have to adjust by 1 word to get s 2-word-aligned.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   977
      __ tbz(s, exact_log2(wordSize), aligned);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   978
      __ ldr(tmp, Address(__ adjust(s, direction * wordSize, is_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   979
      __ str(tmp, Address(__ adjust(d, direction * wordSize, is_backwards)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   980
      __ sub(count, count, wordSize/granularity);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   981
    } else {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   982
      if (is_backwards) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   983
        __ andr(rscratch2, s, 2 * wordSize - 1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   984
      } else {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   985
        __ neg(rscratch2, s);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   986
        __ andr(rscratch2, rscratch2, 2 * wordSize - 1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   987
      }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   988
      // rscratch2 is the byte adjustment needed to align s.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   989
      __ cbz(rscratch2, aligned);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   990
      __ lsr(rscratch2, rscratch2, exact_log2(granularity));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   991
      __ sub(count, count, rscratch2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   992
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   993
#if 0
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   994
      // ?? This code is only correct for a disjoint copy.  It may or
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   995
      // may not make sense to use it in that case.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   996
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   997
      // Copy the first pair; s and d may not be aligned.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   998
      __ ldp(t0, t1, Address(s, is_backwards ? -2 * wordSize : 0));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
   999
      __ stp(t0, t1, Address(d, is_backwards ? -2 * wordSize : 0));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1000
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1001
      // Align s and d, adjust count
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1002
      if (is_backwards) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1003
        __ sub(s, s, rscratch2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1004
        __ sub(d, d, rscratch2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1005
      } else {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1006
        __ add(s, s, rscratch2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1007
        __ add(d, d, rscratch2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1008
      }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1009
#else
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1010
      copy_memory_small(s, d, rscratch2, rscratch1, step);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1011
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1012
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1013
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1014
    __ cmp(count, 16/granularity);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1015
    __ br(Assembler::LT, tail);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1016
    __ bind(aligned);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1017
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1018
    // s is now 2-word-aligned.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1019
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1020
    // We have a count of units and some trailing bytes.  Adjust the
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1021
    // count and do a bulk copy of words.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1022
    __ lsr(rscratch2, count, exact_log2(wordSize/granularity));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1023
    if (direction == copy_forwards)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1024
      __ bl(copy_f);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1025
    else
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1026
      __ bl(copy_b);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1027
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1028
    // And the tail.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1029
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1030
    __ bind(tail);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1031
    copy_memory_small(s, d, count, tmp, step);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1032
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1033
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1034
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1035
  void clobber_registers() {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1036
#ifdef ASSERT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1037
    __ mov(rscratch1, (uint64_t)0xdeadbeef);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1038
    __ orr(rscratch1, rscratch1, rscratch1, Assembler::LSL, 32);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1039
    for (Register r = r3; r <= r18; r++)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1040
      if (r != rscratch1) __ mov(r, rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1041
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1042
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1043
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1044
  // Scan over array at a for count oops, verifying each one.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1045
  // Preserves a and count, clobbers rscratch1 and rscratch2.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1046
  void verify_oop_array (size_t size, Register a, Register count, Register temp) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1047
    Label loop, end;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1048
    __ mov(rscratch1, a);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1049
    __ mov(rscratch2, zr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1050
    __ bind(loop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1051
    __ cmp(rscratch2, count);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1052
    __ br(Assembler::HS, end);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1053
    if (size == (size_t)wordSize) {
35119
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1054
      __ ldr(temp, Address(a, rscratch2, Address::lsl(exact_log2(size))));
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1055
      __ verify_oop(temp);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1056
    } else {
35119
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1057
      __ ldrw(r16, Address(a, rscratch2, Address::lsl(exact_log2(size))));
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1058
      __ decode_heap_oop(temp); // calls verify_oop
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1059
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1060
    __ add(rscratch2, rscratch2, size);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1061
    __ b(loop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1062
    __ bind(end);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1063
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1064
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1065
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1066
  //   aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1067
  //             ignored
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1068
  //   is_oop  - true => oop array, so generate store check code
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1069
  //   name    - stub name string
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1070
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1071
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1072
  //   c_rarg0   - source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1073
  //   c_rarg1   - destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1074
  //   c_rarg2   - element count, treated as ssize_t, can be zero
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1075
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1076
  // If 'from' and/or 'to' are aligned on 4-byte boundaries, we let
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1077
  // the hardware handle it.  The two dwords within qwords that span
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1078
  // cache line boundaries will still be loaded and stored atomicly.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1079
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1080
  // Side Effects:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1081
  //   disjoint_int_copy_entry is set to the no-overlap entry point
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1082
  //   used by generate_conjoint_int_oop_copy().
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1083
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1084
  address generate_disjoint_copy(size_t size, bool aligned, bool is_oop, address *entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1085
                                  const char *name, bool dest_uninitialized = false) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1086
    Register s = c_rarg0, d = c_rarg1, count = c_rarg2;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1087
    __ align(CodeEntryAlignment);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1088
    StubCodeMark mark(this, "StubRoutines", name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1089
    address start = __ pc();
35119
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1090
    __ enter();
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1091
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1092
    if (entry != NULL) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1093
      *entry = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1094
      // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1095
      BLOCK_COMMENT("Entry:");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1096
    }
35119
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1097
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1098
    if (is_oop) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1099
      __ push(RegSet::of(d, count), sp);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1100
      // no registers are destroyed by this call
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1101
      gen_write_ref_array_pre_barrier(d, count, dest_uninitialized);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1102
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1103
    copy_memory(aligned, s, d, count, rscratch1, size);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1104
    if (is_oop) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1105
      __ pop(RegSet::of(d, count), sp);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1106
      if (VerifyOops)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1107
        verify_oop_array(size, d, count, r16);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1108
      __ sub(count, count, 1); // make an inclusive end pointer
35119
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1109
      __ lea(count, Address(d, count, Address::lsl(exact_log2(size))));
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1110
      gen_write_ref_array_post_barrier(d, count, rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1111
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1112
    __ leave();
35119
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1113
    __ mov(r0, zr); // return 0
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1114
    __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1115
#ifdef BUILTIN_SIM
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1116
    {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1117
      AArch64Simulator *sim = AArch64Simulator::get_current(UseSimulatorCache, DisableBCCheck);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1118
      sim->notifyCompile(const_cast<char*>(name), start);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1119
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1120
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1121
    return start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1122
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1123
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1124
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1125
  //   aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1126
  //             ignored
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1127
  //   is_oop  - true => oop array, so generate store check code
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1128
  //   name    - stub name string
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1129
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1130
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1131
  //   c_rarg0   - source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1132
  //   c_rarg1   - destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1133
  //   c_rarg2   - element count, treated as ssize_t, can be zero
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1134
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1135
  // If 'from' and/or 'to' are aligned on 4-byte boundaries, we let
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1136
  // the hardware handle it.  The two dwords within qwords that span
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1137
  // cache line boundaries will still be loaded and stored atomicly.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1138
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1139
  address generate_conjoint_copy(size_t size, bool aligned, bool is_oop, address nooverlap_target,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1140
                                 address *entry, const char *name,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1141
                                 bool dest_uninitialized = false) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1142
    Register s = c_rarg0, d = c_rarg1, count = c_rarg2;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1143
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1144
    StubCodeMark mark(this, "StubRoutines", name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1145
    address start = __ pc();
35119
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1146
    __ enter();
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1147
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1148
    if (entry != NULL) {
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1149
      *entry = __ pc();
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1150
      // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1151
      BLOCK_COMMENT("Entry:");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1152
    }
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1153
    __ cmp(d, s);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1154
    __ br(Assembler::LS, nooverlap_target);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1155
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1156
    if (is_oop) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1157
      __ push(RegSet::of(d, count), sp);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1158
      // no registers are destroyed by this call
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1159
      gen_write_ref_array_pre_barrier(d, count, dest_uninitialized);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1160
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1161
    copy_memory(aligned, s, d, count, rscratch1, -size);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1162
    if (is_oop) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1163
      __ pop(RegSet::of(d, count), sp);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1164
      if (VerifyOops)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1165
        verify_oop_array(size, d, count, r16);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1166
      __ sub(count, count, 1); // make an inclusive end pointer
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1167
      __ lea(count, Address(d, count, Address::uxtw(exact_log2(size))));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1168
      gen_write_ref_array_post_barrier(d, count, rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1169
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1170
    __ leave();
35119
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1171
    __ mov(r0, zr); // return 0
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1172
    __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1173
#ifdef BUILTIN_SIM
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1174
    {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1175
      AArch64Simulator *sim = AArch64Simulator::get_current(UseSimulatorCache, DisableBCCheck);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1176
      sim->notifyCompile(const_cast<char*>(name), start);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1177
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1178
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1179
    return start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1180
}
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1181
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1182
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1183
  //   aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1184
  //             ignored
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1185
  //   name    - stub name string
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1186
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1187
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1188
  //   c_rarg0   - source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1189
  //   c_rarg1   - destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1190
  //   c_rarg2   - element count, treated as ssize_t, can be zero
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1191
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1192
  // If 'from' and/or 'to' are aligned on 4-, 2-, or 1-byte boundaries,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1193
  // we let the hardware handle it.  The one to eight bytes within words,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1194
  // dwords or qwords that span cache line boundaries will still be loaded
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1195
  // and stored atomically.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1196
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1197
  // Side Effects:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1198
  //   disjoint_byte_copy_entry is set to the no-overlap entry point  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1199
  // If 'from' and/or 'to' are aligned on 4-, 2-, or 1-byte boundaries,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1200
  // we let the hardware handle it.  The one to eight bytes within words,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1201
  // dwords or qwords that span cache line boundaries will still be loaded
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1202
  // and stored atomically.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1203
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1204
  // Side Effects:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1205
  //   disjoint_byte_copy_entry is set to the no-overlap entry point
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1206
  //   used by generate_conjoint_byte_copy().
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1207
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1208
  address generate_disjoint_byte_copy(bool aligned, address* entry, const char *name) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1209
    const bool not_oop = false;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1210
    return generate_disjoint_copy(sizeof (jbyte), aligned, not_oop, entry, name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1211
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1212
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1213
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1214
  //   aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1215
  //             ignored
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1216
  //   name    - stub name string
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1217
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1218
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1219
  //   c_rarg0   - source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1220
  //   c_rarg1   - destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1221
  //   c_rarg2   - element count, treated as ssize_t, can be zero
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1222
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1223
  // If 'from' and/or 'to' are aligned on 4-, 2-, or 1-byte boundaries,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1224
  // we let the hardware handle it.  The one to eight bytes within words,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1225
  // dwords or qwords that span cache line boundaries will still be loaded
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1226
  // and stored atomically.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1227
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1228
  address generate_conjoint_byte_copy(bool aligned, address nooverlap_target,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1229
                                      address* entry, const char *name) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1230
    const bool not_oop = false;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1231
    return generate_conjoint_copy(sizeof (jbyte), aligned, not_oop, nooverlap_target, entry, name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1232
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1233
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1234
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1235
  //   aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1236
  //             ignored
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1237
  //   name    - stub name string
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1238
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1239
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1240
  //   c_rarg0   - source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1241
  //   c_rarg1   - destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1242
  //   c_rarg2   - element count, treated as ssize_t, can be zero
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1243
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1244
  // If 'from' and/or 'to' are aligned on 4- or 2-byte boundaries, we
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1245
  // let the hardware handle it.  The two or four words within dwords
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1246
  // or qwords that span cache line boundaries will still be loaded
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1247
  // and stored atomically.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1248
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1249
  // Side Effects:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1250
  //   disjoint_short_copy_entry is set to the no-overlap entry point
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1251
  //   used by generate_conjoint_short_copy().
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1252
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1253
  address generate_disjoint_short_copy(bool aligned,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1254
                                       address* entry, const char *name) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1255
    const bool not_oop = false;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1256
    return generate_disjoint_copy(sizeof (jshort), aligned, not_oop, entry, name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1257
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1258
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1259
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1260
  //   aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1261
  //             ignored
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1262
  //   name    - stub name string
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1263
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1264
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1265
  //   c_rarg0   - source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1266
  //   c_rarg1   - destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1267
  //   c_rarg2   - element count, treated as ssize_t, can be zero
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1268
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1269
  // If 'from' and/or 'to' are aligned on 4- or 2-byte boundaries, we
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1270
  // let the hardware handle it.  The two or four words within dwords
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1271
  // or qwords that span cache line boundaries will still be loaded
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1272
  // and stored atomically.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1273
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1274
  address generate_conjoint_short_copy(bool aligned, address nooverlap_target,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1275
                                       address *entry, const char *name) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1276
    const bool not_oop = false;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1277
    return generate_conjoint_copy(sizeof (jshort), aligned, not_oop, nooverlap_target, entry, name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1278
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1279
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1280
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1281
  //   aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1282
  //             ignored
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1283
  //   name    - stub name string
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1284
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1285
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1286
  //   c_rarg0   - source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1287
  //   c_rarg1   - destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1288
  //   c_rarg2   - element count, treated as ssize_t, can be zero
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1289
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1290
  // If 'from' and/or 'to' are aligned on 4-byte boundaries, we let
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1291
  // the hardware handle it.  The two dwords within qwords that span
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1292
  // cache line boundaries will still be loaded and stored atomicly.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1293
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1294
  // Side Effects:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1295
  //   disjoint_int_copy_entry is set to the no-overlap entry point
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1296
  //   used by generate_conjoint_int_oop_copy().
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1297
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1298
  address generate_disjoint_int_copy(bool aligned, address *entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1299
                                         const char *name, bool dest_uninitialized = false) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1300
    const bool not_oop = false;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1301
    return generate_disjoint_copy(sizeof (jint), aligned, not_oop, entry, name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1302
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1303
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1304
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1305
  //   aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1306
  //             ignored
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1307
  //   name    - stub name string
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1308
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1309
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1310
  //   c_rarg0   - source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1311
  //   c_rarg1   - destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1312
  //   c_rarg2   - element count, treated as ssize_t, can be zero
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1313
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1314
  // If 'from' and/or 'to' are aligned on 4-byte boundaries, we let
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1315
  // the hardware handle it.  The two dwords within qwords that span
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1316
  // cache line boundaries will still be loaded and stored atomicly.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1317
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1318
  address generate_conjoint_int_copy(bool aligned, address nooverlap_target,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1319
                                     address *entry, const char *name,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1320
                                     bool dest_uninitialized = false) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1321
    const bool not_oop = false;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1322
    return generate_conjoint_copy(sizeof (jint), aligned, not_oop, nooverlap_target, entry, name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1323
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1324
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1325
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1326
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1327
  //   aligned - true => Input and output aligned on a HeapWord boundary == 8 bytes
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1328
  //             ignored
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1329
  //   name    - stub name string
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1330
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1331
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1332
  //   c_rarg0   - source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1333
  //   c_rarg1   - destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1334
  //   c_rarg2   - element count, treated as size_t, can be zero
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1335
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1336
  // Side Effects:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1337
  //   disjoint_oop_copy_entry or disjoint_long_copy_entry is set to the
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1338
  //   no-overlap entry point used by generate_conjoint_long_oop_copy().
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1339
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1340
  address generate_disjoint_long_copy(bool aligned, address *entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1341
                                          const char *name, bool dest_uninitialized = false) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1342
    const bool not_oop = false;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1343
    return generate_disjoint_copy(sizeof (jlong), aligned, not_oop, entry, name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1344
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1345
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1346
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1347
  //   aligned - true => Input and output aligned on a HeapWord boundary == 8 bytes
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1348
  //             ignored
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1349
  //   name    - stub name string
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1350
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1351
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1352
  //   c_rarg0   - source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1353
  //   c_rarg1   - destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1354
  //   c_rarg2   - element count, treated as size_t, can be zero
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1355
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1356
  address generate_conjoint_long_copy(bool aligned,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1357
                                      address nooverlap_target, address *entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1358
                                      const char *name, bool dest_uninitialized = false) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1359
    const bool not_oop = false;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1360
    return generate_conjoint_copy(sizeof (jlong), aligned, not_oop, nooverlap_target, entry, name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1361
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1362
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1363
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1364
  //   aligned - true => Input and output aligned on a HeapWord boundary == 8 bytes
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1365
  //             ignored
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1366
  //   name    - stub name string
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1367
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1368
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1369
  //   c_rarg0   - source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1370
  //   c_rarg1   - destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1371
  //   c_rarg2   - element count, treated as size_t, can be zero
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1372
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1373
  // Side Effects:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1374
  //   disjoint_oop_copy_entry or disjoint_long_copy_entry is set to the
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1375
  //   no-overlap entry point used by generate_conjoint_long_oop_copy().
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1376
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1377
  address generate_disjoint_oop_copy(bool aligned, address *entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1378
                                     const char *name, bool dest_uninitialized = false) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1379
    const bool is_oop = true;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1380
    const size_t size = UseCompressedOops ? sizeof (jint) : sizeof (jlong);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1381
    return generate_disjoint_copy(size, aligned, is_oop, entry, name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1382
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1383
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1384
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1385
  //   aligned - true => Input and output aligned on a HeapWord boundary == 8 bytes
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1386
  //             ignored
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1387
  //   name    - stub name string
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1388
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1389
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1390
  //   c_rarg0   - source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1391
  //   c_rarg1   - destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1392
  //   c_rarg2   - element count, treated as size_t, can be zero
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1393
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1394
  address generate_conjoint_oop_copy(bool aligned,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1395
                                     address nooverlap_target, address *entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1396
                                     const char *name, bool dest_uninitialized = false) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1397
    const bool is_oop = true;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1398
    const size_t size = UseCompressedOops ? sizeof (jint) : sizeof (jlong);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1399
    return generate_conjoint_copy(size, aligned, is_oop, nooverlap_target, entry, name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1400
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1401
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1402
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1403
  // Helper for generating a dynamic type check.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1404
  // Smashes rscratch1.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1405
  void generate_type_check(Register sub_klass,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1406
                           Register super_check_offset,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1407
                           Register super_klass,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1408
                           Label& L_success) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1409
    assert_different_registers(sub_klass, super_check_offset, super_klass);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1410
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1411
    BLOCK_COMMENT("type_check:");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1412
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1413
    Label L_miss;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1414
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1415
    __ check_klass_subtype_fast_path(sub_klass, super_klass, noreg,        &L_success, &L_miss, NULL,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1416
                                     super_check_offset);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1417
    __ check_klass_subtype_slow_path(sub_klass, super_klass, noreg, noreg, &L_success, NULL);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1418
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1419
    // Fall through on failure!
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1420
    __ BIND(L_miss);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1421
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1422
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1423
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1424
  //  Generate checkcasting array copy stub
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1425
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1426
  //  Input:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1427
  //    c_rarg0   - source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1428
  //    c_rarg1   - destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1429
  //    c_rarg2   - element count, treated as ssize_t, can be zero
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1430
  //    c_rarg3   - size_t ckoff (super_check_offset)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1431
  //    c_rarg4   - oop ckval (super_klass)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1432
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1433
  //  Output:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1434
  //    r0 ==  0  -  success
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1435
  //    r0 == -1^K - failure, where K is partial transfer count
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1436
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1437
  address generate_checkcast_copy(const char *name, address *entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1438
                                  bool dest_uninitialized = false) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1439
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1440
    Label L_load_element, L_store_element, L_do_card_marks, L_done, L_done_pop;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1441
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1442
    // Input registers (after setup_arg_regs)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1443
    const Register from        = c_rarg0;   // source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1444
    const Register to          = c_rarg1;   // destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1445
    const Register count       = c_rarg2;   // elementscount
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1446
    const Register ckoff       = c_rarg3;   // super_check_offset
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1447
    const Register ckval       = c_rarg4;   // super_klass
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1448
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1449
    // Registers used as temps (r18, r19, r20 are save-on-entry)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1450
    const Register count_save  = r21;       // orig elementscount
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1451
    const Register start_to    = r20;       // destination array start address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1452
    const Register copied_oop  = r18;       // actual oop copied
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1453
    const Register r19_klass   = r19;       // oop._klass
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1454
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1455
    //---------------------------------------------------------------
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1456
    // Assembler stub will be used for this call to arraycopy
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1457
    // if the two arrays are subtypes of Object[] but the
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1458
    // destination array type is not equal to or a supertype
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1459
    // of the source type.  Each element must be separately
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1460
    // checked.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1461
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1462
    assert_different_registers(from, to, count, ckoff, ckval, start_to,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1463
                               copied_oop, r19_klass, count_save);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1464
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1465
    __ align(CodeEntryAlignment);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1466
    StubCodeMark mark(this, "StubRoutines", name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1467
    address start = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1468
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1469
    __ enter(); // required for proper stackwalking of RuntimeStub frame
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1470
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1471
#ifdef ASSERT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1472
    // caller guarantees that the arrays really are different
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1473
    // otherwise, we would have to make conjoint checks
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1474
    { Label L;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1475
      array_overlap_test(L, TIMES_OOP);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1476
      __ stop("checkcast_copy within a single array");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1477
      __ bind(L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1478
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1479
#endif //ASSERT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1480
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1481
    // Caller of this entry point must set up the argument registers.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1482
    if (entry != NULL) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1483
      *entry = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1484
      BLOCK_COMMENT("Entry:");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1485
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1486
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1487
     // Empty array:  Nothing to do.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1488
    __ cbz(count, L_done);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1489
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1490
    __ push(RegSet::of(r18, r19, r20, r21), sp);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1491
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1492
#ifdef ASSERT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1493
    BLOCK_COMMENT("assert consistent ckoff/ckval");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1494
    // The ckoff and ckval must be mutually consistent,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1495
    // even though caller generates both.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1496
    { Label L;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1497
      int sco_offset = in_bytes(Klass::super_check_offset_offset());
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1498
      __ ldrw(start_to, Address(ckval, sco_offset));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1499
      __ cmpw(ckoff, start_to);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1500
      __ br(Assembler::EQ, L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1501
      __ stop("super_check_offset inconsistent");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1502
      __ bind(L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1503
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1504
#endif //ASSERT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1505
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1506
    // save the original count
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1507
    __ mov(count_save, count);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1508
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1509
    // Copy from low to high addresses
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1510
    __ mov(start_to, to);              // Save destination array start address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1511
    __ b(L_load_element);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1512
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1513
    // ======== begin loop ========
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1514
    // (Loop is rotated; its entry is L_load_element.)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1515
    // Loop control:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1516
    //   for (; count != 0; count--) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1517
    //     copied_oop = load_heap_oop(from++);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1518
    //     ... generate_type_check ...;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1519
    //     store_heap_oop(to++, copied_oop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1520
    //   }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1521
    __ align(OptoLoopAlignment);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1522
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1523
    __ BIND(L_store_element);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1524
    __ store_heap_oop(__ post(to, UseCompressedOops ? 4 : 8), copied_oop);  // store the oop
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1525
    __ sub(count, count, 1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1526
    __ cbz(count, L_do_card_marks);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1527
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1528
    // ======== loop entry is here ========
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1529
    __ BIND(L_load_element);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1530
    __ load_heap_oop(copied_oop, __ post(from, UseCompressedOops ? 4 : 8)); // load the oop
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1531
    __ cbz(copied_oop, L_store_element);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1532
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1533
    __ load_klass(r19_klass, copied_oop);// query the object klass
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1534
    generate_type_check(r19_klass, ckoff, ckval, L_store_element);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1535
    // ======== end loop ========
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1536
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1537
    // It was a real error; we must depend on the caller to finish the job.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1538
    // Register count = remaining oops, count_orig = total oops.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1539
    // Emit GC store barriers for the oops we have copied and report
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1540
    // their number to the caller.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1541
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1542
    __ subs(count, count_save, count);     // K = partially copied oop count
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1543
    __ eon(count, count, zr);                   // report (-1^K) to caller
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1544
    __ br(Assembler::EQ, L_done_pop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1545
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1546
    __ BIND(L_do_card_marks);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1547
    __ add(to, to, -heapOopSize);         // make an inclusive end pointer
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1548
    gen_write_ref_array_post_barrier(start_to, to, rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1549
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1550
    __ bind(L_done_pop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1551
    __ pop(RegSet::of(r18, r19, r20, r21), sp);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1552
    inc_counter_np(SharedRuntime::_checkcast_array_copy_ctr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1553
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1554
    __ bind(L_done);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1555
    __ mov(r0, count);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1556
    __ leave();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1557
    __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1558
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1559
    return start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1560
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1561
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1562
  // Perform range checks on the proposed arraycopy.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1563
  // Kills temp, but nothing else.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1564
  // Also, clean the sign bits of src_pos and dst_pos.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1565
  void arraycopy_range_checks(Register src,     // source array oop (c_rarg0)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1566
                              Register src_pos, // source position (c_rarg1)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1567
                              Register dst,     // destination array oo (c_rarg2)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1568
                              Register dst_pos, // destination position (c_rarg3)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1569
                              Register length,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1570
                              Register temp,
35119
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1571
                              Label& L_failed) {
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1572
    BLOCK_COMMENT("arraycopy_range_checks:");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1573
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1574
    assert_different_registers(rscratch1, temp);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1575
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1576
    //  if (src_pos + length > arrayOop(src)->length())  FAIL;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1577
    __ ldrw(rscratch1, Address(src, arrayOopDesc::length_offset_in_bytes()));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1578
    __ addw(temp, length, src_pos);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1579
    __ cmpw(temp, rscratch1);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1580
    __ br(Assembler::HI, L_failed);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1581
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1582
    //  if (dst_pos + length > arrayOop(dst)->length())  FAIL;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1583
    __ ldrw(rscratch1, Address(dst, arrayOopDesc::length_offset_in_bytes()));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1584
    __ addw(temp, length, dst_pos);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1585
    __ cmpw(temp, rscratch1);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1586
    __ br(Assembler::HI, L_failed);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1587
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1588
    // Have to clean up high 32 bits of 'src_pos' and 'dst_pos'.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1589
    __ movw(src_pos, src_pos);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1590
    __ movw(dst_pos, dst_pos);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1591
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1592
    BLOCK_COMMENT("arraycopy_range_checks done");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1593
  }
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1594
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1595
  // These stubs get called from some dumb test routine.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1596
  // I'll write them properly when they're called from
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1597
  // something that's actually doing something.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1598
  static void fake_arraycopy_stub(address src, address dst, int count) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1599
    assert(count == 0, "huh?");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1600
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1601
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1602
35119
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1603
  //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1604
  //  Generate 'unsafe' array copy stub
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1605
  //  Though just as safe as the other stubs, it takes an unscaled
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1606
  //  size_t argument instead of an element count.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1607
  //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1608
  //  Input:
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1609
  //    c_rarg0   - source array address
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1610
  //    c_rarg1   - destination array address
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1611
  //    c_rarg2   - byte count, treated as ssize_t, can be zero
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1612
  //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1613
  // Examines the alignment of the operands and dispatches
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1614
  // to a long, int, short, or byte copy loop.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1615
  //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1616
  address generate_unsafe_copy(const char *name,
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1617
                               address byte_copy_entry) {
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1618
#ifdef PRODUCT
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1619
    return StubRoutines::_jbyte_arraycopy;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1620
#else
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1621
    __ align(CodeEntryAlignment);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1622
    StubCodeMark mark(this, "StubRoutines", name);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1623
    address start = __ pc();
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1624
    __ enter(); // required for proper stackwalking of RuntimeStub frame
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1625
    // bump this on entry, not on exit:
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1626
    __ lea(rscratch2, ExternalAddress((address)&SharedRuntime::_unsafe_array_copy_ctr));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1627
    __ incrementw(Address(rscratch2));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1628
    __ b(RuntimeAddress(byte_copy_entry));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1629
    return start;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1630
#endif
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1631
  }
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1632
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1633
  //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1634
  //  Generate generic array copy stubs
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1635
  //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1636
  //  Input:
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1637
  //    c_rarg0    -  src oop
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1638
  //    c_rarg1    -  src_pos (32-bits)
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1639
  //    c_rarg2    -  dst oop
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1640
  //    c_rarg3    -  dst_pos (32-bits)
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1641
  //    c_rarg4    -  element count (32-bits)
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1642
  //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1643
  //  Output:
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1644
  //    r0 ==  0  -  success
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1645
  //    r0 == -1^K - failure, where K is partial transfer count
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1646
  //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1647
  address generate_generic_copy(const char *name,
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1648
                                address byte_copy_entry, address short_copy_entry,
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1649
                                address int_copy_entry, address oop_copy_entry,
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1650
                                address long_copy_entry, address checkcast_copy_entry) {
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1651
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1652
    Label L_failed, L_failed_0, L_objArray;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1653
    Label L_copy_bytes, L_copy_shorts, L_copy_ints, L_copy_longs;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1654
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1655
    // Input registers
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1656
    const Register src        = c_rarg0;  // source array oop
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1657
    const Register src_pos    = c_rarg1;  // source position
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1658
    const Register dst        = c_rarg2;  // destination array oop
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1659
    const Register dst_pos    = c_rarg3;  // destination position
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1660
    const Register length     = c_rarg4;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1661
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1662
    StubCodeMark mark(this, "StubRoutines", name);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1663
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1664
    __ align(CodeEntryAlignment);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1665
    address start = __ pc();
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1666
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1667
    __ enter(); // required for proper stackwalking of RuntimeStub frame
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1668
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1669
    // bump this on entry, not on exit:
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1670
    inc_counter_np(SharedRuntime::_generic_array_copy_ctr);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1671
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1672
    //-----------------------------------------------------------------------
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1673
    // Assembler stub will be used for this call to arraycopy
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1674
    // if the following conditions are met:
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1675
    //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1676
    // (1) src and dst must not be null.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1677
    // (2) src_pos must not be negative.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1678
    // (3) dst_pos must not be negative.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1679
    // (4) length  must not be negative.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1680
    // (5) src klass and dst klass should be the same and not NULL.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1681
    // (6) src and dst should be arrays.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1682
    // (7) src_pos + length must not exceed length of src.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1683
    // (8) dst_pos + length must not exceed length of dst.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1684
    //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1685
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1686
    //  if (src == NULL) return -1;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1687
    __ cbz(src, L_failed);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1688
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1689
    //  if (src_pos < 0) return -1;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1690
    __ tbnz(src_pos, 31, L_failed);  // i.e. sign bit set
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1691
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1692
    //  if (dst == NULL) return -1;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1693
    __ cbz(dst, L_failed);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1694
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1695
    //  if (dst_pos < 0) return -1;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1696
    __ tbnz(dst_pos, 31, L_failed);  // i.e. sign bit set
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1697
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1698
    // registers used as temp
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1699
    const Register scratch_length    = r16; // elements count to copy
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1700
    const Register scratch_src_klass = r17; // array klass
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1701
    const Register lh                = r18; // layout helper
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1702
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1703
    //  if (length < 0) return -1;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1704
    __ movw(scratch_length, length);        // length (elements count, 32-bits value)
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1705
    __ tbnz(scratch_length, 31, L_failed);  // i.e. sign bit set
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1706
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1707
    __ load_klass(scratch_src_klass, src);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1708
#ifdef ASSERT
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1709
    //  assert(src->klass() != NULL);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1710
    {
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1711
      BLOCK_COMMENT("assert klasses not null {");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1712
      Label L1, L2;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1713
      __ cbnz(scratch_src_klass, L2);   // it is broken if klass is NULL
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1714
      __ bind(L1);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1715
      __ stop("broken null klass");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1716
      __ bind(L2);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1717
      __ load_klass(rscratch1, dst);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1718
      __ cbz(rscratch1, L1);     // this would be broken also
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1719
      BLOCK_COMMENT("} assert klasses not null done");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1720
    }
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1721
#endif
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1722
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1723
    // Load layout helper (32-bits)
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1724
    //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1725
    //  |array_tag|     | header_size | element_type |     |log2_element_size|
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1726
    // 32        30    24            16              8     2                 0
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1727
    //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1728
    //   array_tag: typeArray = 0x3, objArray = 0x2, non-array = 0x0
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1729
    //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1730
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1731
    const int lh_offset = in_bytes(Klass::layout_helper_offset());
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1732
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1733
    // Handle objArrays completely differently...
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1734
    const jint objArray_lh = Klass::array_layout_helper(T_OBJECT);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1735
    __ ldrw(lh, Address(scratch_src_klass, lh_offset));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1736
    __ movw(rscratch1, objArray_lh);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1737
    __ eorw(rscratch2, lh, rscratch1);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1738
    __ cbzw(rscratch2, L_objArray);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1739
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1740
    //  if (src->klass() != dst->klass()) return -1;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1741
    __ load_klass(rscratch2, dst);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1742
    __ eor(rscratch2, rscratch2, scratch_src_klass);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1743
    __ cbnz(rscratch2, L_failed);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1744
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1745
    //  if (!src->is_Array()) return -1;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1746
    __ tbz(lh, 31, L_failed);  // i.e. (lh >= 0)
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1747
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1748
    // At this point, it is known to be a typeArray (array_tag 0x3).
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1749
#ifdef ASSERT
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1750
    {
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1751
      BLOCK_COMMENT("assert primitive array {");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1752
      Label L;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1753
      __ movw(rscratch2, Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1754
      __ cmpw(lh, rscratch2);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1755
      __ br(Assembler::GE, L);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1756
      __ stop("must be a primitive array");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1757
      __ bind(L);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1758
      BLOCK_COMMENT("} assert primitive array done");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1759
    }
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1760
#endif
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1761
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1762
    arraycopy_range_checks(src, src_pos, dst, dst_pos, scratch_length,
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1763
                           rscratch2, L_failed);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1764
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1765
    // TypeArrayKlass
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1766
    //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1767
    // src_addr = (src + array_header_in_bytes()) + (src_pos << log2elemsize);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1768
    // dst_addr = (dst + array_header_in_bytes()) + (dst_pos << log2elemsize);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1769
    //
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1770
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1771
    const Register rscratch1_offset = rscratch1;    // array offset
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1772
    const Register r18_elsize = lh; // element size
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1773
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1774
    __ ubfx(rscratch1_offset, lh, Klass::_lh_header_size_shift,
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1775
           exact_log2(Klass::_lh_header_size_mask+1));   // array_offset
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1776
    __ add(src, src, rscratch1_offset);           // src array offset
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1777
    __ add(dst, dst, rscratch1_offset);           // dst array offset
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1778
    BLOCK_COMMENT("choose copy loop based on element size");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1779
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1780
    // next registers should be set before the jump to corresponding stub
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1781
    const Register from     = c_rarg0;  // source array address
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1782
    const Register to       = c_rarg1;  // destination array address
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1783
    const Register count    = c_rarg2;  // elements count
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1784
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1785
    // 'from', 'to', 'count' registers should be set in such order
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1786
    // since they are the same as 'src', 'src_pos', 'dst'.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1787
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1788
    assert(Klass::_lh_log2_element_size_shift == 0, "fix this code");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1789
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1790
    // The possible values of elsize are 0-3, i.e. exact_log2(element
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1791
    // size in bytes).  We do a simple bitwise binary search.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1792
  __ BIND(L_copy_bytes);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1793
    __ tbnz(r18_elsize, 1, L_copy_ints);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1794
    __ tbnz(r18_elsize, 0, L_copy_shorts);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1795
    __ lea(from, Address(src, src_pos));// src_addr
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1796
    __ lea(to,   Address(dst, dst_pos));// dst_addr
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1797
    __ movw(count, scratch_length); // length
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1798
    __ b(RuntimeAddress(byte_copy_entry));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1799
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1800
  __ BIND(L_copy_shorts);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1801
    __ lea(from, Address(src, src_pos, Address::lsl(1)));// src_addr
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1802
    __ lea(to,   Address(dst, dst_pos, Address::lsl(1)));// dst_addr
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1803
    __ movw(count, scratch_length); // length
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1804
    __ b(RuntimeAddress(short_copy_entry));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1805
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1806
  __ BIND(L_copy_ints);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1807
    __ tbnz(r18_elsize, 0, L_copy_longs);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1808
    __ lea(from, Address(src, src_pos, Address::lsl(2)));// src_addr
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1809
    __ lea(to,   Address(dst, dst_pos, Address::lsl(2)));// dst_addr
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1810
    __ movw(count, scratch_length); // length
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1811
    __ b(RuntimeAddress(int_copy_entry));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1812
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1813
  __ BIND(L_copy_longs);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1814
#ifdef ASSERT
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1815
    {
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1816
      BLOCK_COMMENT("assert long copy {");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1817
      Label L;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1818
      __ andw(lh, lh, Klass::_lh_log2_element_size_mask); // lh -> r18_elsize
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1819
      __ cmpw(r18_elsize, LogBytesPerLong);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1820
      __ br(Assembler::EQ, L);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1821
      __ stop("must be long copy, but elsize is wrong");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1822
      __ bind(L);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1823
      BLOCK_COMMENT("} assert long copy done");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1824
    }
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1825
#endif
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1826
    __ lea(from, Address(src, src_pos, Address::lsl(3)));// src_addr
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1827
    __ lea(to,   Address(dst, dst_pos, Address::lsl(3)));// dst_addr
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1828
    __ movw(count, scratch_length); // length
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1829
    __ b(RuntimeAddress(long_copy_entry));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1830
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1831
    // ObjArrayKlass
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1832
  __ BIND(L_objArray);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1833
    // live at this point:  scratch_src_klass, scratch_length, src[_pos], dst[_pos]
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1834
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1835
    Label L_plain_copy, L_checkcast_copy;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1836
    //  test array classes for subtyping
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1837
    __ load_klass(r18, dst);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1838
    __ cmp(scratch_src_klass, r18); // usual case is exact equality
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1839
    __ br(Assembler::NE, L_checkcast_copy);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1840
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1841
    // Identically typed arrays can be copied without element-wise checks.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1842
    arraycopy_range_checks(src, src_pos, dst, dst_pos, scratch_length,
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1843
                           rscratch2, L_failed);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1844
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1845
    __ lea(from, Address(src, src_pos, Address::lsl(3)));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1846
    __ add(from, from, arrayOopDesc::base_offset_in_bytes(T_OBJECT));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1847
    __ lea(to, Address(dst, dst_pos, Address::lsl(3)));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1848
    __ add(to, to, arrayOopDesc::base_offset_in_bytes(T_OBJECT));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1849
    __ movw(count, scratch_length); // length
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1850
  __ BIND(L_plain_copy);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1851
    __ b(RuntimeAddress(oop_copy_entry));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1852
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1853
  __ BIND(L_checkcast_copy);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1854
    // live at this point:  scratch_src_klass, scratch_length, r18 (dst_klass)
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1855
    {
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1856
      // Before looking at dst.length, make sure dst is also an objArray.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1857
      __ ldrw(rscratch1, Address(r18, lh_offset));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1858
      __ movw(rscratch2, objArray_lh);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1859
      __ eorw(rscratch1, rscratch1, rscratch2);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1860
      __ cbnzw(rscratch1, L_failed);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1861
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1862
      // It is safe to examine both src.length and dst.length.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1863
      arraycopy_range_checks(src, src_pos, dst, dst_pos, scratch_length,
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1864
                             r18, L_failed);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1865
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1866
      const Register rscratch2_dst_klass = rscratch2;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1867
      __ load_klass(rscratch2_dst_klass, dst); // reload
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1868
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1869
      // Marshal the base address arguments now, freeing registers.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1870
      __ lea(from, Address(src, src_pos, Address::lsl(3)));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1871
      __ add(from, from, arrayOopDesc::base_offset_in_bytes(T_OBJECT));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1872
      __ lea(to, Address(dst, dst_pos, Address::lsl(3)));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1873
      __ add(to, to, arrayOopDesc::base_offset_in_bytes(T_OBJECT));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1874
      __ movw(count, length);           // length (reloaded)
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1875
      Register sco_temp = c_rarg3;      // this register is free now
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1876
      assert_different_registers(from, to, count, sco_temp,
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1877
                                 rscratch2_dst_klass, scratch_src_klass);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1878
      // assert_clean_int(count, sco_temp);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1879
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1880
      // Generate the type check.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1881
      const int sco_offset = in_bytes(Klass::super_check_offset_offset());
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1882
      __ ldrw(sco_temp, Address(rscratch2_dst_klass, sco_offset));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1883
      // assert_clean_int(sco_temp, r18);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1884
      generate_type_check(scratch_src_klass, sco_temp, rscratch2_dst_klass, L_plain_copy);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1885
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1886
      // Fetch destination element klass from the ObjArrayKlass header.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1887
      int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset());
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1888
      __ ldr(rscratch2_dst_klass, Address(rscratch2_dst_klass, ek_offset));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1889
      __ ldrw(sco_temp, Address(rscratch2_dst_klass, sco_offset));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1890
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1891
      // the checkcast_copy loop needs two extra arguments:
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1892
      assert(c_rarg3 == sco_temp, "#3 already in place");
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1893
      // Set up arguments for checkcast_copy_entry.
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1894
      __ mov(c_rarg4, rscratch2_dst_klass);  // dst.klass.element_klass
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1895
      __ b(RuntimeAddress(checkcast_copy_entry));
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1896
    }
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1897
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1898
  __ BIND(L_failed);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1899
    __ mov(r0, -1);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1900
    __ leave();   // required for proper stackwalking of RuntimeStub frame
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1901
    __ ret(lr);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1902
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1903
    return start;
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1904
  }
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1905
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1906
  void generate_arraycopy_stubs() {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1907
    address entry;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1908
    address entry_jbyte_arraycopy;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1909
    address entry_jshort_arraycopy;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1910
    address entry_jint_arraycopy;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1911
    address entry_oop_arraycopy;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1912
    address entry_jlong_arraycopy;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1913
    address entry_checkcast_arraycopy;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1914
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1915
    generate_copy_longs(copy_f, r0, r1, rscratch2, copy_forwards);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1916
    generate_copy_longs(copy_b, r0, r1, rscratch2, copy_backwards);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1917
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1918
    //*** jbyte
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1919
    // Always need aligned and unaligned versions
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1920
    StubRoutines::_jbyte_disjoint_arraycopy         = generate_disjoint_byte_copy(false, &entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1921
                                                                                  "jbyte_disjoint_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1922
    StubRoutines::_jbyte_arraycopy                  = generate_conjoint_byte_copy(false, entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1923
                                                                                  &entry_jbyte_arraycopy,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1924
                                                                                  "jbyte_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1925
    StubRoutines::_arrayof_jbyte_disjoint_arraycopy = generate_disjoint_byte_copy(true, &entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1926
                                                                                  "arrayof_jbyte_disjoint_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1927
    StubRoutines::_arrayof_jbyte_arraycopy          = generate_conjoint_byte_copy(true, entry, NULL,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1928
                                                                                  "arrayof_jbyte_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1929
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1930
    //*** jshort
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1931
    // Always need aligned and unaligned versions
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1932
    StubRoutines::_jshort_disjoint_arraycopy         = generate_disjoint_short_copy(false, &entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1933
                                                                                    "jshort_disjoint_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1934
    StubRoutines::_jshort_arraycopy                  = generate_conjoint_short_copy(false, entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1935
                                                                                    &entry_jshort_arraycopy,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1936
                                                                                    "jshort_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1937
    StubRoutines::_arrayof_jshort_disjoint_arraycopy = generate_disjoint_short_copy(true, &entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1938
                                                                                    "arrayof_jshort_disjoint_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1939
    StubRoutines::_arrayof_jshort_arraycopy          = generate_conjoint_short_copy(true, entry, NULL,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1940
                                                                                    "arrayof_jshort_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1941
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1942
    //*** jint
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1943
    // Aligned versions
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1944
    StubRoutines::_arrayof_jint_disjoint_arraycopy = generate_disjoint_int_copy(true, &entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1945
                                                                                "arrayof_jint_disjoint_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1946
    StubRoutines::_arrayof_jint_arraycopy          = generate_conjoint_int_copy(true, entry, &entry_jint_arraycopy,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1947
                                                                                "arrayof_jint_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1948
    // In 64 bit we need both aligned and unaligned versions of jint arraycopy.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1949
    // entry_jint_arraycopy always points to the unaligned version
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1950
    StubRoutines::_jint_disjoint_arraycopy         = generate_disjoint_int_copy(false, &entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1951
                                                                                "jint_disjoint_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1952
    StubRoutines::_jint_arraycopy                  = generate_conjoint_int_copy(false, entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1953
                                                                                &entry_jint_arraycopy,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1954
                                                                                "jint_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1955
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1956
    //*** jlong
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1957
    // It is always aligned
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1958
    StubRoutines::_arrayof_jlong_disjoint_arraycopy = generate_disjoint_long_copy(true, &entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1959
                                                                                  "arrayof_jlong_disjoint_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1960
    StubRoutines::_arrayof_jlong_arraycopy          = generate_conjoint_long_copy(true, entry, &entry_jlong_arraycopy,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1961
                                                                                  "arrayof_jlong_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1962
    StubRoutines::_jlong_disjoint_arraycopy         = StubRoutines::_arrayof_jlong_disjoint_arraycopy;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1963
    StubRoutines::_jlong_arraycopy                  = StubRoutines::_arrayof_jlong_arraycopy;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1964
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1965
    //*** oops
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1966
    {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1967
      // With compressed oops we need unaligned versions; notice that
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1968
      // we overwrite entry_oop_arraycopy.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1969
      bool aligned = !UseCompressedOops;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1970
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1971
      StubRoutines::_arrayof_oop_disjoint_arraycopy
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1972
        = generate_disjoint_oop_copy(aligned, &entry, "arrayof_oop_disjoint_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1973
      StubRoutines::_arrayof_oop_arraycopy
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1974
        = generate_conjoint_oop_copy(aligned, entry, &entry_oop_arraycopy, "arrayof_oop_arraycopy");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1975
      // Aligned versions without pre-barriers
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1976
      StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1977
        = generate_disjoint_oop_copy(aligned, &entry, "arrayof_oop_disjoint_arraycopy_uninit",
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1978
                                     /*dest_uninitialized*/true);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1979
      StubRoutines::_arrayof_oop_arraycopy_uninit
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1980
        = generate_conjoint_oop_copy(aligned, entry, NULL, "arrayof_oop_arraycopy_uninit",
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1981
                                     /*dest_uninitialized*/true);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1982
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1983
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1984
    StubRoutines::_oop_disjoint_arraycopy            = StubRoutines::_arrayof_oop_disjoint_arraycopy;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1985
    StubRoutines::_oop_arraycopy                     = StubRoutines::_arrayof_oop_arraycopy;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1986
    StubRoutines::_oop_disjoint_arraycopy_uninit     = StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1987
    StubRoutines::_oop_arraycopy_uninit              = StubRoutines::_arrayof_oop_arraycopy_uninit;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1988
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1989
    StubRoutines::_checkcast_arraycopy        = generate_checkcast_copy("checkcast_arraycopy", &entry_checkcast_arraycopy);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1990
    StubRoutines::_checkcast_arraycopy_uninit = generate_checkcast_copy("checkcast_arraycopy_uninit", NULL,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  1991
                                                                        /*dest_uninitialized*/true);
35119
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1992
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1993
    StubRoutines::_unsafe_arraycopy    = generate_unsafe_copy("unsafe_arraycopy",
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1994
                                                              entry_jbyte_arraycopy);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1995
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1996
    StubRoutines::_generic_arraycopy   = generate_generic_copy("generic_arraycopy",
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1997
                                                               entry_jbyte_arraycopy,
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1998
                                                               entry_jshort_arraycopy,
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  1999
                                                               entry_jint_arraycopy,
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  2000
                                                               entry_oop_arraycopy,
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  2001
                                                               entry_jlong_arraycopy,
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  2002
                                                               entry_checkcast_arraycopy);
7af8d9f08a25 8145320: Create unsafe_arraycopy and generic_arraycopy for AArch64
aph
parents: 33198
diff changeset
  2003
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2004
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2005
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2006
  void generate_math_stubs() { Unimplemented(); }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2007
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2008
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2009
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2010
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2011
  //   c_rarg0   - source byte array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2012
  //   c_rarg1   - destination byte array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2013
  //   c_rarg2   - K (key) in little endian int array
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2014
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2015
  address generate_aescrypt_encryptBlock() {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2016
    __ align(CodeEntryAlignment);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2017
    StubCodeMark mark(this, "StubRoutines", "aescrypt_encryptBlock");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2018
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2019
    Label L_doLast;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2020
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2021
    const Register from        = c_rarg0;  // source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2022
    const Register to          = c_rarg1;  // destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2023
    const Register key         = c_rarg2;  // key array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2024
    const Register keylen      = rscratch1;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2025
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2026
    address start = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2027
    __ enter();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2028
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2029
    __ ldrw(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2030
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2031
    __ ld1(v0, __ T16B, from); // get 16 bytes of input
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2032
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2033
    __ ld1(v1, v2, v3, v4, __ T16B, __ post(key, 64));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2034
    __ rev32(v1, __ T16B, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2035
    __ rev32(v2, __ T16B, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2036
    __ rev32(v3, __ T16B, v3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2037
    __ rev32(v4, __ T16B, v4);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2038
    __ aese(v0, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2039
    __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2040
    __ aese(v0, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2041
    __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2042
    __ aese(v0, v3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2043
    __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2044
    __ aese(v0, v4);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2045
    __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2046
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2047
    __ ld1(v1, v2, v3, v4, __ T16B, __ post(key, 64));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2048
    __ rev32(v1, __ T16B, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2049
    __ rev32(v2, __ T16B, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2050
    __ rev32(v3, __ T16B, v3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2051
    __ rev32(v4, __ T16B, v4);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2052
    __ aese(v0, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2053
    __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2054
    __ aese(v0, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2055
    __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2056
    __ aese(v0, v3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2057
    __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2058
    __ aese(v0, v4);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2059
    __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2060
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2061
    __ ld1(v1, v2, __ T16B, __ post(key, 32));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2062
    __ rev32(v1, __ T16B, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2063
    __ rev32(v2, __ T16B, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2064
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2065
    __ cmpw(keylen, 44);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2066
    __ br(Assembler::EQ, L_doLast);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2067
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2068
    __ aese(v0, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2069
    __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2070
    __ aese(v0, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2071
    __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2072
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2073
    __ ld1(v1, v2, __ T16B, __ post(key, 32));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2074
    __ rev32(v1, __ T16B, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2075
    __ rev32(v2, __ T16B, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2076
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2077
    __ cmpw(keylen, 52);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2078
    __ br(Assembler::EQ, L_doLast);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2079
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2080
    __ aese(v0, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2081
    __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2082
    __ aese(v0, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2083
    __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2084
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2085
    __ ld1(v1, v2, __ T16B, __ post(key, 32));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2086
    __ rev32(v1, __ T16B, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2087
    __ rev32(v2, __ T16B, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2088
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2089
    __ BIND(L_doLast);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2090
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2091
    __ aese(v0, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2092
    __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2093
    __ aese(v0, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2094
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2095
    __ ld1(v1, __ T16B, key);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2096
    __ rev32(v1, __ T16B, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2097
    __ eor(v0, __ T16B, v0, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2098
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2099
    __ st1(v0, __ T16B, to);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2100
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2101
    __ mov(r0, 0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2102
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2103
    __ leave();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2104
    __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2105
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2106
    return start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2107
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2108
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2109
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2110
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2111
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2112
  //   c_rarg0   - source byte array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2113
  //   c_rarg1   - destination byte array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2114
  //   c_rarg2   - K (key) in little endian int array
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2115
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2116
  address generate_aescrypt_decryptBlock() {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2117
    assert(UseAES, "need AES instructions and misaligned SSE support");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2118
    __ align(CodeEntryAlignment);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2119
    StubCodeMark mark(this, "StubRoutines", "aescrypt_decryptBlock");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2120
    Label L_doLast;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2121
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2122
    const Register from        = c_rarg0;  // source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2123
    const Register to          = c_rarg1;  // destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2124
    const Register key         = c_rarg2;  // key array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2125
    const Register keylen      = rscratch1;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2126
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2127
    address start = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2128
    __ enter(); // required for proper stackwalking of RuntimeStub frame
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2129
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2130
    __ ldrw(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2131
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2132
    __ ld1(v0, __ T16B, from); // get 16 bytes of input
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2133
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2134
    __ ld1(v5, __ T16B, __ post(key, 16));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2135
    __ rev32(v5, __ T16B, v5);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2136
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2137
    __ ld1(v1, v2, v3, v4, __ T16B, __ post(key, 64));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2138
    __ rev32(v1, __ T16B, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2139
    __ rev32(v2, __ T16B, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2140
    __ rev32(v3, __ T16B, v3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2141
    __ rev32(v4, __ T16B, v4);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2142
    __ aesd(v0, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2143
    __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2144
    __ aesd(v0, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2145
    __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2146
    __ aesd(v0, v3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2147
    __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2148
    __ aesd(v0, v4);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2149
    __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2150
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2151
    __ ld1(v1, v2, v3, v4, __ T16B, __ post(key, 64));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2152
    __ rev32(v1, __ T16B, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2153
    __ rev32(v2, __ T16B, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2154
    __ rev32(v3, __ T16B, v3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2155
    __ rev32(v4, __ T16B, v4);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2156
    __ aesd(v0, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2157
    __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2158
    __ aesd(v0, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2159
    __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2160
    __ aesd(v0, v3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2161
    __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2162
    __ aesd(v0, v4);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2163
    __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2164
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2165
    __ ld1(v1, v2, __ T16B, __ post(key, 32));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2166
    __ rev32(v1, __ T16B, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2167
    __ rev32(v2, __ T16B, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2168
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2169
    __ cmpw(keylen, 44);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2170
    __ br(Assembler::EQ, L_doLast);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2171
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2172
    __ aesd(v0, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2173
    __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2174
    __ aesd(v0, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2175
    __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2176
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2177
    __ ld1(v1, v2, __ T16B, __ post(key, 32));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2178
    __ rev32(v1, __ T16B, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2179
    __ rev32(v2, __ T16B, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2180
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2181
    __ cmpw(keylen, 52);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2182
    __ br(Assembler::EQ, L_doLast);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2184
    __ aesd(v0, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2185
    __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2186
    __ aesd(v0, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2187
    __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2188
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2189
    __ ld1(v1, v2, __ T16B, __ post(key, 32));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2190
    __ rev32(v1, __ T16B, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2191
    __ rev32(v2, __ T16B, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2192
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2193
    __ BIND(L_doLast);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2194
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2195
    __ aesd(v0, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2196
    __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2197
    __ aesd(v0, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2198
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2199
    __ eor(v0, __ T16B, v0, v5);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2200
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2201
    __ st1(v0, __ T16B, to);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2202
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2203
    __ mov(r0, 0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2204
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2205
    __ leave();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2206
    __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2207
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2208
    return start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2209
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2210
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2211
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2212
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2213
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2214
  //   c_rarg0   - source byte array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2215
  //   c_rarg1   - destination byte array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2216
  //   c_rarg2   - K (key) in little endian int array
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2217
  //   c_rarg3   - r vector byte array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2218
  //   c_rarg4   - input length
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2219
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2220
  // Output:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2221
  //   x0        - input length
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2222
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2223
  address generate_cipherBlockChaining_encryptAESCrypt() {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2224
    assert(UseAES, "need AES instructions and misaligned SSE support");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2225
    __ align(CodeEntryAlignment);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2226
    StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_encryptAESCrypt");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2227
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2228
    Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2229
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2230
    const Register from        = c_rarg0;  // source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2231
    const Register to          = c_rarg1;  // destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2232
    const Register key         = c_rarg2;  // key array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2233
    const Register rvec        = c_rarg3;  // r byte array initialized from initvector array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2234
                                           // and left with the results of the last encryption block
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2235
    const Register len_reg     = c_rarg4;  // src len (must be multiple of blocksize 16)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2236
    const Register keylen      = rscratch1;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2237
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2238
    address start = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2239
      __ enter();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2240
30553
27039e118599 8080586: aarch64: hotspot test compiler/codegen/7184394/TestAESMain.java fails
enevill
parents: 30225
diff changeset
  2241
      __ mov(rscratch2, len_reg);
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2242
      __ ldrw(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2243
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2244
      __ ld1(v0, __ T16B, rvec);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2245
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2246
      __ cmpw(keylen, 52);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2247
      __ br(Assembler::CC, L_loadkeys_44);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2248
      __ br(Assembler::EQ, L_loadkeys_52);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2249
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2250
      __ ld1(v17, v18, __ T16B, __ post(key, 32));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2251
      __ rev32(v17, __ T16B, v17);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2252
      __ rev32(v18, __ T16B, v18);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2253
    __ BIND(L_loadkeys_52);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2254
      __ ld1(v19, v20, __ T16B, __ post(key, 32));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2255
      __ rev32(v19, __ T16B, v19);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2256
      __ rev32(v20, __ T16B, v20);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2257
    __ BIND(L_loadkeys_44);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2258
      __ ld1(v21, v22, v23, v24, __ T16B, __ post(key, 64));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2259
      __ rev32(v21, __ T16B, v21);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2260
      __ rev32(v22, __ T16B, v22);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2261
      __ rev32(v23, __ T16B, v23);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2262
      __ rev32(v24, __ T16B, v24);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2263
      __ ld1(v25, v26, v27, v28, __ T16B, __ post(key, 64));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2264
      __ rev32(v25, __ T16B, v25);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2265
      __ rev32(v26, __ T16B, v26);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2266
      __ rev32(v27, __ T16B, v27);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2267
      __ rev32(v28, __ T16B, v28);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2268
      __ ld1(v29, v30, v31, __ T16B, key);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2269
      __ rev32(v29, __ T16B, v29);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2270
      __ rev32(v30, __ T16B, v30);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2271
      __ rev32(v31, __ T16B, v31);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2272
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2273
    __ BIND(L_aes_loop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2274
      __ ld1(v1, __ T16B, __ post(from, 16));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2275
      __ eor(v0, __ T16B, v0, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2276
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2277
      __ br(Assembler::CC, L_rounds_44);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2278
      __ br(Assembler::EQ, L_rounds_52);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2279
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2280
      __ aese(v0, v17); __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2281
      __ aese(v0, v18); __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2282
    __ BIND(L_rounds_52);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2283
      __ aese(v0, v19); __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2284
      __ aese(v0, v20); __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2285
    __ BIND(L_rounds_44);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2286
      __ aese(v0, v21); __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2287
      __ aese(v0, v22); __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2288
      __ aese(v0, v23); __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2289
      __ aese(v0, v24); __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2290
      __ aese(v0, v25); __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2291
      __ aese(v0, v26); __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2292
      __ aese(v0, v27); __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2293
      __ aese(v0, v28); __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2294
      __ aese(v0, v29); __ aesmc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2295
      __ aese(v0, v30);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2296
      __ eor(v0, __ T16B, v0, v31);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2297
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2298
      __ st1(v0, __ T16B, __ post(to, 16));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2299
      __ sub(len_reg, len_reg, 16);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2300
      __ cbnz(len_reg, L_aes_loop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2301
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2302
      __ st1(v0, __ T16B, rvec);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2303
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2304
      __ mov(r0, rscratch2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2305
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2306
      __ leave();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2307
      __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2308
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2309
      return start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2310
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2311
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2312
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2313
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2314
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2315
  //   c_rarg0   - source byte array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2316
  //   c_rarg1   - destination byte array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2317
  //   c_rarg2   - K (key) in little endian int array
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2318
  //   c_rarg3   - r vector byte array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2319
  //   c_rarg4   - input length
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2320
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2321
  // Output:
35135
twisti
parents: 35119 34664
diff changeset
  2322
  //   r0        - input length
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2323
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2324
  address generate_cipherBlockChaining_decryptAESCrypt() {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2325
    assert(UseAES, "need AES instructions and misaligned SSE support");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2326
    __ align(CodeEntryAlignment);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2327
    StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_decryptAESCrypt");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2328
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2329
    Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2330
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2331
    const Register from        = c_rarg0;  // source array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2332
    const Register to          = c_rarg1;  // destination array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2333
    const Register key         = c_rarg2;  // key array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2334
    const Register rvec        = c_rarg3;  // r byte array initialized from initvector array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2335
                                           // and left with the results of the last encryption block
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2336
    const Register len_reg     = c_rarg4;  // src len (must be multiple of blocksize 16)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2337
    const Register keylen      = rscratch1;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2338
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2339
    address start = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2340
      __ enter();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2341
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2342
      __ mov(rscratch2, len_reg);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2343
      __ ldrw(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2344
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2345
      __ ld1(v2, __ T16B, rvec);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2346
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2347
      __ ld1(v31, __ T16B, __ post(key, 16));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2348
      __ rev32(v31, __ T16B, v31);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2349
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2350
      __ cmpw(keylen, 52);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2351
      __ br(Assembler::CC, L_loadkeys_44);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2352
      __ br(Assembler::EQ, L_loadkeys_52);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2353
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2354
      __ ld1(v17, v18, __ T16B, __ post(key, 32));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2355
      __ rev32(v17, __ T16B, v17);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2356
      __ rev32(v18, __ T16B, v18);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2357
    __ BIND(L_loadkeys_52);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2358
      __ ld1(v19, v20, __ T16B, __ post(key, 32));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2359
      __ rev32(v19, __ T16B, v19);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2360
      __ rev32(v20, __ T16B, v20);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2361
    __ BIND(L_loadkeys_44);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2362
      __ ld1(v21, v22, v23, v24, __ T16B, __ post(key, 64));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2363
      __ rev32(v21, __ T16B, v21);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2364
      __ rev32(v22, __ T16B, v22);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2365
      __ rev32(v23, __ T16B, v23);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2366
      __ rev32(v24, __ T16B, v24);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2367
      __ ld1(v25, v26, v27, v28, __ T16B, __ post(key, 64));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2368
      __ rev32(v25, __ T16B, v25);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2369
      __ rev32(v26, __ T16B, v26);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2370
      __ rev32(v27, __ T16B, v27);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2371
      __ rev32(v28, __ T16B, v28);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2372
      __ ld1(v29, v30, __ T16B, key);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2373
      __ rev32(v29, __ T16B, v29);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2374
      __ rev32(v30, __ T16B, v30);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2375
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2376
    __ BIND(L_aes_loop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2377
      __ ld1(v0, __ T16B, __ post(from, 16));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2378
      __ orr(v1, __ T16B, v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2379
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2380
      __ br(Assembler::CC, L_rounds_44);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2381
      __ br(Assembler::EQ, L_rounds_52);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2382
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2383
      __ aesd(v0, v17); __ aesimc(v0, v0);
34664
41c821224dd7 8144201: aarch64: jdk/test/com/sun/net/httpserver/Test6a.java fails with --enable-unlimited-crypto
fyang
parents: 33198
diff changeset
  2384
      __ aesd(v0, v18); __ aesimc(v0, v0);
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2385
    __ BIND(L_rounds_52);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2386
      __ aesd(v0, v19); __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2387
      __ aesd(v0, v20); __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2388
    __ BIND(L_rounds_44);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2389
      __ aesd(v0, v21); __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2390
      __ aesd(v0, v22); __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2391
      __ aesd(v0, v23); __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2392
      __ aesd(v0, v24); __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2393
      __ aesd(v0, v25); __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2394
      __ aesd(v0, v26); __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2395
      __ aesd(v0, v27); __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2396
      __ aesd(v0, v28); __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2397
      __ aesd(v0, v29); __ aesimc(v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2398
      __ aesd(v0, v30);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2399
      __ eor(v0, __ T16B, v0, v31);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2400
      __ eor(v0, __ T16B, v0, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2401
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2402
      __ st1(v0, __ T16B, __ post(to, 16));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2403
      __ orr(v2, __ T16B, v1, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2404
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2405
      __ sub(len_reg, len_reg, 16);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2406
      __ cbnz(len_reg, L_aes_loop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2407
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2408
      __ st1(v2, __ T16B, rvec);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2409
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2410
      __ mov(r0, rscratch2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2411
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2412
      __ leave();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2413
      __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2414
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2415
    return start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2416
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2417
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2418
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2419
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2420
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2421
  //   c_rarg0   - byte[]  source+offset
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2422
  //   c_rarg1   - int[]   SHA.state
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2423
  //   c_rarg2   - int     offset
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2424
  //   c_rarg3   - int     limit
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2425
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2426
  address generate_sha1_implCompress(bool multi_block, const char *name) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2427
    __ align(CodeEntryAlignment);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2428
    StubCodeMark mark(this, "StubRoutines", name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2429
    address start = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2430
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2431
    Register buf   = c_rarg0;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2432
    Register state = c_rarg1;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2433
    Register ofs   = c_rarg2;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2434
    Register limit = c_rarg3;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2435
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2436
    Label keys;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2437
    Label sha1_loop;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2438
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2439
    // load the keys into v0..v3
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2440
    __ adr(rscratch1, keys);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2441
    __ ld4r(v0, v1, v2, v3, __ T4S, Address(rscratch1));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2442
    // load 5 words state into v6, v7
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2443
    __ ldrq(v6, Address(state, 0));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2444
    __ ldrs(v7, Address(state, 16));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2445
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2446
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2447
    __ BIND(sha1_loop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2448
    // load 64 bytes of data into v16..v19
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2449
    __ ld1(v16, v17, v18, v19, __ T4S, multi_block ? __ post(buf, 64) : buf);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2450
    __ rev32(v16, __ T16B, v16);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2451
    __ rev32(v17, __ T16B, v17);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2452
    __ rev32(v18, __ T16B, v18);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2453
    __ rev32(v19, __ T16B, v19);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2454
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2455
    // do the sha1
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2456
    __ addv(v4, __ T4S, v16, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2457
    __ orr(v20, __ T16B, v6, v6);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2458
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2459
    FloatRegister d0 = v16;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2460
    FloatRegister d1 = v17;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2461
    FloatRegister d2 = v18;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2462
    FloatRegister d3 = v19;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2463
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2464
    for (int round = 0; round < 20; round++) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2465
      FloatRegister tmp1 = (round & 1) ? v4 : v5;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2466
      FloatRegister tmp2 = (round & 1) ? v21 : v22;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2467
      FloatRegister tmp3 = round ? ((round & 1) ? v22 : v21) : v7;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2468
      FloatRegister tmp4 = (round & 1) ? v5 : v4;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2469
      FloatRegister key = (round < 4) ? v0 : ((round < 9) ? v1 : ((round < 14) ? v2 : v3));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2470
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2471
      if (round < 16) __ sha1su0(d0, __ T4S, d1, d2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2472
      if (round < 19) __ addv(tmp1, __ T4S, d1, key);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2473
      __ sha1h(tmp2, __ T4S, v20);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2474
      if (round < 5)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2475
        __ sha1c(v20, __ T4S, tmp3, tmp4);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2476
      else if (round < 10 || round >= 15)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2477
        __ sha1p(v20, __ T4S, tmp3, tmp4);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2478
      else
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2479
        __ sha1m(v20, __ T4S, tmp3, tmp4);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2480
      if (round < 16) __ sha1su1(d0, __ T4S, d3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2481
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2482
      tmp1 = d0; d0 = d1; d1 = d2; d2 = d3; d3 = tmp1;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2483
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2484
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2485
    __ addv(v7, __ T2S, v7, v21);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2486
    __ addv(v6, __ T4S, v6, v20);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2487
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2488
    if (multi_block) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2489
      __ add(ofs, ofs, 64);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2490
      __ cmp(ofs, limit);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2491
      __ br(Assembler::LE, sha1_loop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2492
      __ mov(c_rarg0, ofs); // return ofs
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2493
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2494
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2495
    __ strq(v6, Address(state, 0));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2496
    __ strs(v7, Address(state, 16));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2497
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2498
    __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2499
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2500
    __ bind(keys);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2501
    __ emit_int32(0x5a827999);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2502
    __ emit_int32(0x6ed9eba1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2503
    __ emit_int32(0x8f1bbcdc);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2504
    __ emit_int32(0xca62c1d6);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2505
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2506
    return start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2507
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2508
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2509
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2510
  // Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2511
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2512
  // Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2513
  //   c_rarg0   - byte[]  source+offset
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2514
  //   c_rarg1   - int[]   SHA.state
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2515
  //   c_rarg2   - int     offset
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2516
  //   c_rarg3   - int     limit
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2517
  //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2518
  address generate_sha256_implCompress(bool multi_block, const char *name) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2519
    static const uint32_t round_consts[64] = {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2520
      0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2521
      0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2522
      0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2523
      0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2524
      0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2525
      0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2526
      0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2527
      0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2528
      0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2529
      0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2530
      0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2531
      0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2532
      0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2533
      0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2534
      0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2535
      0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2536
    };
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2537
    __ align(CodeEntryAlignment);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2538
    StubCodeMark mark(this, "StubRoutines", name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2539
    address start = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2540
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2541
    Register buf   = c_rarg0;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2542
    Register state = c_rarg1;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2543
    Register ofs   = c_rarg2;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2544
    Register limit = c_rarg3;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2545
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2546
    Label sha1_loop;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2547
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2548
    __ stpd(v8, v9, __ pre(sp, -32));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2549
    __ stpd(v10, v11, Address(sp, 16));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2550
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2551
// dga == v0
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2552
// dgb == v1
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2553
// dg0 == v2
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2554
// dg1 == v3
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2555
// dg2 == v4
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2556
// t0 == v6
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2557
// t1 == v7
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2558
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2559
    // load 16 keys to v16..v31
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2560
    __ lea(rscratch1, ExternalAddress((address)round_consts));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2561
    __ ld1(v16, v17, v18, v19, __ T4S, __ post(rscratch1, 64));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2562
    __ ld1(v20, v21, v22, v23, __ T4S, __ post(rscratch1, 64));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2563
    __ ld1(v24, v25, v26, v27, __ T4S, __ post(rscratch1, 64));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2564
    __ ld1(v28, v29, v30, v31, __ T4S, rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2565
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2566
    // load 8 words (256 bits) state
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2567
    __ ldpq(v0, v1, state);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2568
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2569
    __ BIND(sha1_loop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2570
    // load 64 bytes of data into v8..v11
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2571
    __ ld1(v8, v9, v10, v11, __ T4S, multi_block ? __ post(buf, 64) : buf);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2572
    __ rev32(v8, __ T16B, v8);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2573
    __ rev32(v9, __ T16B, v9);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2574
    __ rev32(v10, __ T16B, v10);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2575
    __ rev32(v11, __ T16B, v11);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2576
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2577
    __ addv(v6, __ T4S, v8, v16);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2578
    __ orr(v2, __ T16B, v0, v0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2579
    __ orr(v3, __ T16B, v1, v1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2580
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2581
    FloatRegister d0 = v8;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2582
    FloatRegister d1 = v9;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2583
    FloatRegister d2 = v10;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2584
    FloatRegister d3 = v11;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2585
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2586
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2587
    for (int round = 0; round < 16; round++) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2588
      FloatRegister tmp1 = (round & 1) ? v6 : v7;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2589
      FloatRegister tmp2 = (round & 1) ? v7 : v6;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2590
      FloatRegister tmp3 = (round & 1) ? v2 : v4;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2591
      FloatRegister tmp4 = (round & 1) ? v4 : v2;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2592
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2593
      if (round < 12) __ sha256su0(d0, __ T4S, d1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2594
       __ orr(v4, __ T16B, v2, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2595
      if (round < 15)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2596
        __ addv(tmp1, __ T4S, d1, as_FloatRegister(round + 17));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2597
      __ sha256h(v2, __ T4S, v3, tmp2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2598
      __ sha256h2(v3, __ T4S, v4, tmp2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2599
      if (round < 12) __ sha256su1(d0, __ T4S, d2, d3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2600
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2601
      tmp1 = d0; d0 = d1; d1 = d2; d2 = d3; d3 = tmp1;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2602
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2603
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2604
    __ addv(v0, __ T4S, v0, v2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2605
    __ addv(v1, __ T4S, v1, v3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2606
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2607
    if (multi_block) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2608
      __ add(ofs, ofs, 64);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2609
      __ cmp(ofs, limit);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2610
      __ br(Assembler::LE, sha1_loop);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2611
      __ mov(c_rarg0, ofs); // return ofs
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2612
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2613
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2614
    __ ldpd(v10, v11, Address(sp, 16));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2615
    __ ldpd(v8, v9, __ post(sp, 32));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2616
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2617
    __ stpq(v0, v1, state);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2618
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2619
    __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2620
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2621
    return start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2622
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2623
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2624
#ifndef BUILTIN_SIM
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2625
  // Safefetch stubs.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2626
  void generate_safefetch(const char* name, int size, address* entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2627
                          address* fault_pc, address* continuation_pc) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2628
    // safefetch signatures:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2629
    //   int      SafeFetch32(int*      adr, int      errValue);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2630
    //   intptr_t SafeFetchN (intptr_t* adr, intptr_t errValue);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2631
    //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2632
    // arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2633
    //   c_rarg0 = adr
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2634
    //   c_rarg1 = errValue
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2635
    //
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2636
    // result:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2637
    //   PPC_RET  = *adr or errValue
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2638
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2639
    StubCodeMark mark(this, "StubRoutines", name);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2640
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2641
    // Entry point, pc or function descriptor.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2642
    *entry = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2643
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2644
    // Load *adr into c_rarg1, may fault.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2645
    *fault_pc = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2646
    switch (size) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2647
      case 4:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2648
        // int32_t
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2649
        __ ldrw(c_rarg1, Address(c_rarg0, 0));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2650
        break;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2651
      case 8:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2652
        // int64_t
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2653
        __ ldr(c_rarg1, Address(c_rarg0, 0));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2654
        break;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2655
      default:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2656
        ShouldNotReachHere();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2657
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2658
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2659
    // return errValue or *adr
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2660
    *continuation_pc = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2661
    __ mov(r0, c_rarg1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2662
    __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2663
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2664
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2665
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2666
  /**
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2667
   *  Arguments:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2668
   *
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2669
   * Inputs:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2670
   *   c_rarg0   - int crc
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2671
   *   c_rarg1   - byte* buf
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2672
   *   c_rarg2   - int length
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2673
   *
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2674
   * Ouput:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2675
   *       rax   - int crc result
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2676
   */
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2677
  address generate_updateBytesCRC32() {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2678
    assert(UseCRC32Intrinsics, "what are we doing here?");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2679
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2680
    __ align(CodeEntryAlignment);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2681
    StubCodeMark mark(this, "StubRoutines", "updateBytesCRC32");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2682
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2683
    address start = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2684
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2685
    const Register crc   = c_rarg0;  // crc
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2686
    const Register buf   = c_rarg1;  // source java byte array address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2687
    const Register len   = c_rarg2;  // length
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2688
    const Register table0 = c_rarg3; // crc_table address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2689
    const Register table1 = c_rarg4;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2690
    const Register table2 = c_rarg5;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2691
    const Register table3 = c_rarg6;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2692
    const Register tmp3 = c_rarg7;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2693
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2694
    BLOCK_COMMENT("Entry:");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2695
    __ enter(); // required for proper stackwalking of RuntimeStub frame
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2696
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2697
    __ kernel_crc32(crc, buf, len,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2698
              table0, table1, table2, table3, rscratch1, rscratch2, tmp3);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2699
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2700
    __ leave(); // required for proper stackwalking of RuntimeStub frame
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2701
    __ ret(lr);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2702
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2703
    return start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2704
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  2705
30225
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  2706
  /**
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  2707
   *  Arguments:
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  2708
   *
31591
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2709
   * Inputs:
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2710
   *   c_rarg0   - int crc
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2711
   *   c_rarg1   - byte* buf
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2712
   *   c_rarg2   - int length
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2713
   *   c_rarg3   - int* table
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2714
   *
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2715
   * Ouput:
32574
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  2716
   *       r0   - int crc result
31591
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2717
   */
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2718
  address generate_updateBytesCRC32C() {
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2719
    assert(UseCRC32CIntrinsics, "what are we doing here?");
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2720
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2721
    __ align(CodeEntryAlignment);
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2722
    StubCodeMark mark(this, "StubRoutines", "updateBytesCRC32C");
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2723
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2724
    address start = __ pc();
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2725
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2726
    const Register crc   = c_rarg0;  // crc
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2727
    const Register buf   = c_rarg1;  // source java byte array address
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2728
    const Register len   = c_rarg2;  // length
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2729
    const Register table0 = c_rarg3; // crc_table address
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2730
    const Register table1 = c_rarg4;
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2731
    const Register table2 = c_rarg5;
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2732
    const Register table3 = c_rarg6;
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2733
    const Register tmp3 = c_rarg7;
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2734
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2735
    BLOCK_COMMENT("Entry:");
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2736
    __ enter(); // required for proper stackwalking of RuntimeStub frame
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2737
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2738
    __ kernel_crc32c(crc, buf, len,
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2739
              table0, table1, table2, table3, rscratch1, rscratch2, tmp3);
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2740
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2741
    __ leave(); // required for proper stackwalking of RuntimeStub frame
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2742
    __ ret(lr);
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2743
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2744
    return start;
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2745
  }
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  2746
33176
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2747
  /***
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2748
   *  Arguments:
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2749
   *
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2750
   *  Inputs:
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2751
   *   c_rarg0   - int   adler
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2752
   *   c_rarg1   - byte* buff
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2753
   *   c_rarg2   - int   len
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2754
   *
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2755
   * Output:
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2756
   *   c_rarg0   - int adler result
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2757
   */
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2758
  address generate_updateBytesAdler32() {
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2759
    __ align(CodeEntryAlignment);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2760
    StubCodeMark mark(this, "StubRoutines", "updateBytesAdler32");
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2761
    address start = __ pc();
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2762
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2763
    Label L_simple_by1_loop, L_nmax, L_nmax_loop, L_by16, L_by16_loop, L_by1_loop, L_do_mod, L_combine, L_by1;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2764
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2765
    // Aliases
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2766
    Register adler  = c_rarg0;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2767
    Register s1     = c_rarg0;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2768
    Register s2     = c_rarg3;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2769
    Register buff   = c_rarg1;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2770
    Register len    = c_rarg2;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2771
    Register nmax  = r4;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2772
    Register base = r5;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2773
    Register count = r6;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2774
    Register temp0 = rscratch1;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2775
    Register temp1 = rscratch2;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2776
    Register temp2 = r7;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2777
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2778
    // Max number of bytes we can process before having to take the mod
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2779
    // 0x15B0 is 5552 in decimal, the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2780
    unsigned long BASE = 0xfff1;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2781
    unsigned long NMAX = 0x15B0;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2782
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2783
    __ mov(base, BASE);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2784
    __ mov(nmax, NMAX);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2785
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2786
    // s1 is initialized to the lower 16 bits of adler
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2787
    // s2 is initialized to the upper 16 bits of adler
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2788
    __ ubfx(s2, adler, 16, 16);  // s2 = ((adler >> 16) & 0xffff)
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2789
    __ uxth(s1, adler);          // s1 = (adler & 0xffff)
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2790
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2791
    // The pipelined loop needs at least 16 elements for 1 iteration
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2792
    // It does check this, but it is more effective to skip to the cleanup loop
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2793
    __ cmp(len, 16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2794
    __ br(Assembler::HS, L_nmax);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2795
    __ cbz(len, L_combine);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2796
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2797
    __ bind(L_simple_by1_loop);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2798
    __ ldrb(temp0, Address(__ post(buff, 1)));
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2799
    __ add(s1, s1, temp0);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2800
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2801
    __ subs(len, len, 1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2802
    __ br(Assembler::HI, L_simple_by1_loop);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2803
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2804
    // s1 = s1 % BASE
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2805
    __ subs(temp0, s1, base);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2806
    __ csel(s1, temp0, s1, Assembler::HS);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2807
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2808
    // s2 = s2 % BASE
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2809
    __ lsr(temp0, s2, 16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2810
    __ lsl(temp1, temp0, 4);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2811
    __ sub(temp1, temp1, temp0);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2812
    __ add(s2, temp1, s2, ext::uxth);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2813
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2814
    __ subs(temp0, s2, base);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2815
    __ csel(s2, temp0, s2, Assembler::HS);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2816
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2817
    __ b(L_combine);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2818
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2819
    __ bind(L_nmax);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2820
    __ subs(len, len, nmax);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2821
    __ sub(count, nmax, 16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2822
    __ br(Assembler::LO, L_by16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2823
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2824
    __ bind(L_nmax_loop);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2825
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2826
    __ ldp(temp0, temp1, Address(__ post(buff, 16)));
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2827
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2828
    __ add(s1, s1, temp0, ext::uxtb);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2829
    __ ubfx(temp2, temp0, 8, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2830
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2831
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2832
    __ ubfx(temp2, temp0, 16, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2833
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2834
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2835
    __ ubfx(temp2, temp0, 24, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2836
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2837
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2838
    __ ubfx(temp2, temp0, 32, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2839
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2840
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2841
    __ ubfx(temp2, temp0, 40, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2842
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2843
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2844
    __ ubfx(temp2, temp0, 48, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2845
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2846
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2847
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2848
    __ add(s1, s1, temp0, Assembler::LSR, 56);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2849
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2850
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2851
    __ add(s1, s1, temp1, ext::uxtb);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2852
    __ ubfx(temp2, temp1, 8, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2853
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2854
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2855
    __ ubfx(temp2, temp1, 16, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2856
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2857
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2858
    __ ubfx(temp2, temp1, 24, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2859
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2860
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2861
    __ ubfx(temp2, temp1, 32, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2862
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2863
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2864
    __ ubfx(temp2, temp1, 40, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2865
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2866
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2867
    __ ubfx(temp2, temp1, 48, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2868
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2869
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2870
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2871
    __ add(s1, s1, temp1, Assembler::LSR, 56);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2872
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2873
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2874
    __ subs(count, count, 16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2875
    __ br(Assembler::HS, L_nmax_loop);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2876
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2877
    // s1 = s1 % BASE
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2878
    __ lsr(temp0, s1, 16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2879
    __ lsl(temp1, temp0, 4);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2880
    __ sub(temp1, temp1, temp0);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2881
    __ add(temp1, temp1, s1, ext::uxth);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2882
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2883
    __ lsr(temp0, temp1, 16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2884
    __ lsl(s1, temp0, 4);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2885
    __ sub(s1, s1, temp0);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2886
    __ add(s1, s1, temp1, ext:: uxth);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2887
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2888
    __ subs(temp0, s1, base);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2889
    __ csel(s1, temp0, s1, Assembler::HS);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2890
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2891
    // s2 = s2 % BASE
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2892
    __ lsr(temp0, s2, 16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2893
    __ lsl(temp1, temp0, 4);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2894
    __ sub(temp1, temp1, temp0);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2895
    __ add(temp1, temp1, s2, ext::uxth);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2896
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2897
    __ lsr(temp0, temp1, 16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2898
    __ lsl(s2, temp0, 4);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2899
    __ sub(s2, s2, temp0);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2900
    __ add(s2, s2, temp1, ext:: uxth);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2901
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2902
    __ subs(temp0, s2, base);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2903
    __ csel(s2, temp0, s2, Assembler::HS);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2904
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2905
    __ subs(len, len, nmax);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2906
    __ sub(count, nmax, 16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2907
    __ br(Assembler::HS, L_nmax_loop);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2908
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2909
    __ bind(L_by16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2910
    __ adds(len, len, count);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2911
    __ br(Assembler::LO, L_by1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2912
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2913
    __ bind(L_by16_loop);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2914
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2915
    __ ldp(temp0, temp1, Address(__ post(buff, 16)));
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2916
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2917
    __ add(s1, s1, temp0, ext::uxtb);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2918
    __ ubfx(temp2, temp0, 8, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2919
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2920
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2921
    __ ubfx(temp2, temp0, 16, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2922
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2923
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2924
    __ ubfx(temp2, temp0, 24, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2925
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2926
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2927
    __ ubfx(temp2, temp0, 32, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2928
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2929
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2930
    __ ubfx(temp2, temp0, 40, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2931
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2932
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2933
    __ ubfx(temp2, temp0, 48, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2934
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2935
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2936
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2937
    __ add(s1, s1, temp0, Assembler::LSR, 56);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2938
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2939
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2940
    __ add(s1, s1, temp1, ext::uxtb);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2941
    __ ubfx(temp2, temp1, 8, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2942
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2943
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2944
    __ ubfx(temp2, temp1, 16, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2945
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2946
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2947
    __ ubfx(temp2, temp1, 24, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2948
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2949
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2950
    __ ubfx(temp2, temp1, 32, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2951
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2952
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2953
    __ ubfx(temp2, temp1, 40, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2954
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2955
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2956
    __ ubfx(temp2, temp1, 48, 8);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2957
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2958
    __ add(s1, s1, temp2);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2959
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2960
    __ add(s1, s1, temp1, Assembler::LSR, 56);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2961
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2962
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2963
    __ subs(len, len, 16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2964
    __ br(Assembler::HS, L_by16_loop);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2965
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2966
    __ bind(L_by1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2967
    __ adds(len, len, 15);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2968
    __ br(Assembler::LO, L_do_mod);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2969
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2970
    __ bind(L_by1_loop);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2971
    __ ldrb(temp0, Address(__ post(buff, 1)));
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2972
    __ add(s1, temp0, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2973
    __ add(s2, s2, s1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2974
    __ subs(len, len, 1);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2975
    __ br(Assembler::HS, L_by1_loop);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2976
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2977
    __ bind(L_do_mod);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2978
    // s1 = s1 % BASE
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2979
    __ lsr(temp0, s1, 16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2980
    __ lsl(temp1, temp0, 4);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2981
    __ sub(temp1, temp1, temp0);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2982
    __ add(temp1, temp1, s1, ext::uxth);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2983
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2984
    __ lsr(temp0, temp1, 16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2985
    __ lsl(s1, temp0, 4);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2986
    __ sub(s1, s1, temp0);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2987
    __ add(s1, s1, temp1, ext:: uxth);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2988
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2989
    __ subs(temp0, s1, base);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2990
    __ csel(s1, temp0, s1, Assembler::HS);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2991
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2992
    // s2 = s2 % BASE
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2993
    __ lsr(temp0, s2, 16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2994
    __ lsl(temp1, temp0, 4);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2995
    __ sub(temp1, temp1, temp0);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2996
    __ add(temp1, temp1, s2, ext::uxth);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2997
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2998
    __ lsr(temp0, temp1, 16);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  2999
    __ lsl(s2, temp0, 4);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3000
    __ sub(s2, s2, temp0);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3001
    __ add(s2, s2, temp1, ext:: uxth);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3002
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3003
    __ subs(temp0, s2, base);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3004
    __ csel(s2, temp0, s2, Assembler::HS);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3005
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3006
    // Combine lower bits and higher bits
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3007
    __ bind(L_combine);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3008
    __ orr(s1, s1, s2, Assembler::LSL, 16); // adler = s1 | (s2 << 16)
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3009
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3010
    __ ret(lr);
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3011
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3012
    return start;
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3013
  }
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  3014
31591
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  3015
  /**
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  3016
   *  Arguments:
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  3017
   *
30225
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3018
   *  Input:
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3019
   *    c_rarg0   - x address
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3020
   *    c_rarg1   - x length
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3021
   *    c_rarg2   - y address
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3022
   *    c_rarg3   - y lenth
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3023
   *    c_rarg4   - z address
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3024
   *    c_rarg5   - z length
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3025
   */
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3026
  address generate_multiplyToLen() {
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3027
    __ align(CodeEntryAlignment);
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3028
    StubCodeMark mark(this, "StubRoutines", "multiplyToLen");
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3029
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3030
    address start = __ pc();
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3031
    const Register x     = r0;
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3032
    const Register xlen  = r1;
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3033
    const Register y     = r2;
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3034
    const Register ylen  = r3;
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3035
    const Register z     = r4;
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3036
    const Register zlen  = r5;
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3037
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3038
    const Register tmp1  = r10;
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3039
    const Register tmp2  = r11;
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3040
    const Register tmp3  = r12;
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3041
    const Register tmp4  = r13;
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3042
    const Register tmp5  = r14;
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3043
    const Register tmp6  = r15;
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3044
    const Register tmp7  = r16;
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3045
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3046
    BLOCK_COMMENT("Entry:");
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3047
    __ enter(); // required for proper stackwalking of RuntimeStub frame
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3048
    __ multiply_to_len(x, xlen, y, ylen, z, zlen, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7);
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3049
    __ leave(); // required for proper stackwalking of RuntimeStub frame
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3050
    __ ret(lr);
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3051
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3052
    return start;
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3053
  }
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3054
32574
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3055
  void ghash_multiply(FloatRegister result_lo, FloatRegister result_hi,
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3056
                      FloatRegister a, FloatRegister b, FloatRegister a1_xor_a0,
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3057
                      FloatRegister tmp1, FloatRegister tmp2, FloatRegister tmp3, FloatRegister tmp4) {
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3058
    // Karatsuba multiplication performs a 128*128 -> 256-bit
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3059
    // multiplication in three 128-bit multiplications and a few
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3060
    // additions.
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3061
    //
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3062
    // (C1:C0) = A1*B1, (D1:D0) = A0*B0, (E1:E0) = (A0+A1)(B0+B1)
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3063
    // (A1:A0)(B1:B0) = C1:(C0+C1+D1+E1):(D1+C0+D0+E0):D0
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3064
    //
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3065
    // Inputs:
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3066
    //
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3067
    // A0 in a.d[0]     (subkey)
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3068
    // A1 in a.d[1]
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3069
    // (A1+A0) in a1_xor_a0.d[0]
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3070
    //
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3071
    // B0 in b.d[0]     (state)
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3072
    // B1 in b.d[1]
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3073
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3074
    __ ext(tmp1, __ T16B, b, b, 0x08);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3075
    __ pmull2(result_hi, __ T1Q, b, a, __ T2D);  // A1*B1
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3076
    __ eor(tmp1, __ T16B, tmp1, b);            // (B1+B0)
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3077
    __ pmull(result_lo,  __ T1Q, b, a, __ T1D);  // A0*B0
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3078
    __ pmull(tmp2, __ T1Q, tmp1, a1_xor_a0, __ T1D); // (A1+A0)(B1+B0)
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3079
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3080
    __ ext(tmp4, __ T16B, result_lo, result_hi, 0x08);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3081
    __ eor(tmp3, __ T16B, result_hi, result_lo); // A1*B1+A0*B0
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3082
    __ eor(tmp2, __ T16B, tmp2, tmp4);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3083
    __ eor(tmp2, __ T16B, tmp2, tmp3);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3084
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3085
    // Register pair <result_hi:result_lo> holds the result of carry-less multiplication
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3086
    __ ins(result_hi, __ D, tmp2, 0, 1);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3087
    __ ins(result_lo, __ D, tmp2, 1, 0);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3088
  }
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3089
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3090
  void ghash_reduce(FloatRegister result, FloatRegister lo, FloatRegister hi,
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3091
                    FloatRegister p, FloatRegister z, FloatRegister t1) {
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3092
    const FloatRegister t0 = result;
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3093
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3094
    // The GCM field polynomial f is z^128 + p(z), where p =
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3095
    // z^7+z^2+z+1.
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3096
    //
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3097
    //    z^128 === -p(z)  (mod (z^128 + p(z)))
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3098
    //
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3099
    // so, given that the product we're reducing is
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3100
    //    a == lo + hi * z^128
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3101
    // substituting,
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3102
    //      === lo - hi * p(z)  (mod (z^128 + p(z)))
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3103
    //
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3104
    // we reduce by multiplying hi by p(z) and subtracting the result
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3105
    // from (i.e. XORing it with) lo.  Because p has no nonzero high
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3106
    // bits we can do this with two 64-bit multiplications, lo*p and
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3107
    // hi*p.
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3108
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3109
    __ pmull2(t0, __ T1Q, hi, p, __ T2D);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3110
    __ ext(t1, __ T16B, t0, z, 8);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3111
    __ eor(hi, __ T16B, hi, t1);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3112
    __ ext(t1, __ T16B, z, t0, 8);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3113
    __ eor(lo, __ T16B, lo, t1);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3114
    __ pmull(t0, __ T1Q, hi, p, __ T1D);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3115
    __ eor(result, __ T16B, lo, t0);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3116
  }
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3117
31961
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3118
  /**
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3119
   *  Arguments:
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3120
   *
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3121
   *  Input:
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3122
   *  c_rarg0   - current state address
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3123
   *  c_rarg1   - H key address
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3124
   *  c_rarg2   - data address
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3125
   *  c_rarg3   - number of blocks
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3126
   *
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3127
   *  Output:
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3128
   *  Updated state at c_rarg0
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3129
   */
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3130
  address generate_ghash_processBlocks() {
32574
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3131
    // Bafflingly, GCM uses little-endian for the byte order, but
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3132
    // big-endian for the bit order.  For example, the polynomial 1 is
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3133
    // represented as the 16-byte string 80 00 00 00 | 12 bytes of 00.
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3134
    //
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3135
    // So, we must either reverse the bytes in each word and do
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3136
    // everything big-endian or reverse the bits in each byte and do
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3137
    // it little-endian.  On AArch64 it's more idiomatic to reverse
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3138
    // the bits in each byte (we have an instruction, RBIT, to do
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3139
    // that) and keep the data in little-endian bit order throught the
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3140
    // calculation, bit-reversing the inputs and outputs.
31961
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3141
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3142
    StubCodeMark mark(this, "StubRoutines", "ghash_processBlocks");
32574
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3143
    __ align(wordSize * 2);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3144
    address p = __ pc();
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3145
    __ emit_int64(0x87);  // The low-order bits of the field
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3146
                          // polynomial (i.e. p = z^7+z^2+z+1)
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3147
                          // repeated in the low and high parts of a
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3148
                          // 128-bit vector
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3149
    __ emit_int64(0x87);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3150
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3151
    __ align(CodeEntryAlignment);
31961
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3152
    address start = __ pc();
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3153
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3154
    Register state   = c_rarg0;
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3155
    Register subkeyH = c_rarg1;
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3156
    Register data    = c_rarg2;
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3157
    Register blocks  = c_rarg3;
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3158
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3159
    FloatRegister vzr = v30;
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3160
    __ eor(vzr, __ T16B, vzr, vzr); // zero register
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3161
32574
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3162
    __ ldrq(v0, Address(state));
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3163
    __ ldrq(v1, Address(subkeyH));
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3164
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3165
    __ rev64(v0, __ T16B, v0);          // Bit-reverse words in state and subkeyH
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3166
    __ rbit(v0, __ T16B, v0);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3167
    __ rev64(v1, __ T16B, v1);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3168
    __ rbit(v1, __ T16B, v1);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3169
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3170
    __ ldrq(v26, p);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3171
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3172
    __ ext(v16, __ T16B, v1, v1, 0x08); // long-swap subkeyH into v1
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3173
    __ eor(v16, __ T16B, v16, v1);      // xor subkeyH into subkeyL (Karatsuba: (A1+A0))
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3174
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3175
    {
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3176
      Label L_ghash_loop;
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3177
      __ bind(L_ghash_loop);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3178
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3179
      __ ldrq(v2, Address(__ post(data, 0x10))); // Load the data, bit
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3180
                                                 // reversing each byte
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3181
      __ rbit(v2, __ T16B, v2);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3182
      __ eor(v2, __ T16B, v0, v2);   // bit-swapped data ^ bit-swapped state
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3183
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3184
      // Multiply state in v2 by subkey in v1
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3185
      ghash_multiply(/*result_lo*/v5, /*result_hi*/v7,
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3186
                     /*a*/v1, /*b*/v2, /*a1_xor_a0*/v16,
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3187
                     /*temps*/v6, v20, v18, v21);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3188
      // Reduce v7:v5 by the field polynomial
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3189
      ghash_reduce(v0, v5, v7, v26, vzr, v20);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3190
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3191
      __ sub(blocks, blocks, 1);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3192
      __ cbnz(blocks, L_ghash_loop);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3193
    }
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3194
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3195
    // The bit-reversed result is at this point in v0
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3196
    __ rev64(v1, __ T16B, v0);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3197
    __ rbit(v1, __ T16B, v1);
6c3b890aa5d9 8134869: AARCH64: GHASH intrinsic is not optimal
aph
parents: 31961
diff changeset
  3198
31961
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3199
    __ st1(v1, __ T16B, state);
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3200
    __ ret(lr);
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3201
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3202
    return start;
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3203
  }
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  3204
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3205
  // Continuation point for throwing of implicit exceptions that are
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3206
  // not handled in the current activation. Fabricates an exception
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3207
  // oop and initiates normal exception dispatching in this
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3208
  // frame. Since we need to preserve callee-saved values (currently
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3209
  // only for C2, but done for C1 as well) we need a callee-saved oop
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3210
  // map and therefore have to make these stubs into RuntimeStubs
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3211
  // rather than BufferBlobs.  If the compiler needs all registers to
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3212
  // be preserved between the fault point and the exception handler
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3213
  // then it must assume responsibility for that in
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3214
  // AbstractCompiler::continuation_for_implicit_null_exception or
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3215
  // continuation_for_implicit_division_by_zero_exception. All other
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3216
  // implicit exceptions (e.g., NullPointerException or
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3217
  // AbstractMethodError on entry) are either at call sites or
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3218
  // otherwise assume that stack unwinding will be initiated, so
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3219
  // caller saved registers were assumed volatile in the compiler.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3220
30225
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3221
#undef __
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3222
#define __ masm->
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  3223
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3224
  address generate_throw_exception(const char* name,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3225
                                   address runtime_entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3226
                                   Register arg1 = noreg,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3227
                                   Register arg2 = noreg) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3228
    // Information about frame layout at time of blocking runtime call.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3229
    // Note that we only have to preserve callee-saved registers since
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3230
    // the compilers are responsible for supplying a continuation point
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3231
    // if they expect all registers to be preserved.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3232
    // n.b. aarch64 asserts that frame::arg_reg_save_area_bytes == 0
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3233
    enum layout {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3234
      rfp_off = 0,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3235
      rfp_off2,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3236
      return_off,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3237
      return_off2,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3238
      framesize // inclusive of return address
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3239
    };
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3240
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3241
    int insts_size = 512;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3242
    int locs_size  = 64;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3243
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3244
    CodeBuffer code(name, insts_size, locs_size);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3245
    OopMapSet* oop_maps  = new OopMapSet();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3246
    MacroAssembler* masm = new MacroAssembler(&code);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3247
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3248
    address start = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3249
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3250
    // This is an inlined and slightly modified version of call_VM
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3251
    // which has the ability to fetch the return PC out of
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3252
    // thread-local storage and also sets up last_Java_sp slightly
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3253
    // differently than the real call_VM
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3254
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3255
    __ enter(); // Save FP and LR before call
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3256
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3257
    assert(is_even(framesize/2), "sp not 16-byte aligned");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3258
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3259
    // lr and fp are already in place
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3260
    __ sub(sp, rfp, ((unsigned)framesize-4) << LogBytesPerInt); // prolog
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3261
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3262
    int frame_complete = __ pc() - start;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3263
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3264
    // Set up last_Java_sp and last_Java_fp
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3265
    address the_pc = __ pc();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3266
    __ set_last_Java_frame(sp, rfp, (address)NULL, rscratch1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3267
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3268
    // Call runtime
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3269
    if (arg1 != noreg) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3270
      assert(arg2 != c_rarg1, "clobbered");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3271
      __ mov(c_rarg1, arg1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3272
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3273
    if (arg2 != noreg) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3274
      __ mov(c_rarg2, arg2);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3275
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3276
    __ mov(c_rarg0, rthread);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3277
    BLOCK_COMMENT("call runtime_entry");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3278
    __ mov(rscratch1, runtime_entry);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3279
    __ blrt(rscratch1, 3 /* number_of_arguments */, 0, 1);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3280
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3281
    // Generate oop map
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3282
    OopMap* map = new OopMap(framesize, 0);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3283
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3284
    oop_maps->add_gc_map(the_pc - start, map);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3285
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3286
    __ reset_last_Java_frame(true, true);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3287
    __ maybe_isb();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3288
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3289
    __ leave();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3290
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3291
    // check for pending exceptions
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3292
#ifdef ASSERT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3293
    Label L;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3294
    __ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset()));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3295
    __ cbnz(rscratch1, L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3296
    __ should_not_reach_here();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3297
    __ bind(L);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3298
#endif // ASSERT
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3299
    __ far_jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3300
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3301
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3302
    // codeBlob framesize is in words (not VMRegImpl::slot_size)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3303
    RuntimeStub* stub =
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3304
      RuntimeStub::new_runtime_stub(name,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3305
                                    &code,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3306
                                    frame_complete,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3307
                                    (framesize >> (LogBytesPerWord - LogBytesPerInt)),
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3308
                                    oop_maps, false);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3309
    return stub->entry_point();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3310
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  3311
31955
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3312
  class MontgomeryMultiplyGenerator : public MacroAssembler {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3313
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3314
    Register Pa_base, Pb_base, Pn_base, Pm_base, inv, Rlen, Ra, Rb, Rm, Rn,
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3315
      Pa, Pb, Pn, Pm, Rhi_ab, Rlo_ab, Rhi_mn, Rlo_mn, t0, t1, t2, Ri, Rj;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3316
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3317
    RegSet _toSave;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3318
    bool _squaring;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3319
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3320
  public:
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3321
    MontgomeryMultiplyGenerator (Assembler *as, bool squaring)
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3322
      : MacroAssembler(as->code()), _squaring(squaring) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3323
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3324
      // Register allocation
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3325
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3326
      Register reg = c_rarg0;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3327
      Pa_base = reg;       // Argument registers
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3328
      if (squaring)
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3329
        Pb_base = Pa_base;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3330
      else
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3331
        Pb_base = ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3332
      Pn_base = ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3333
      Rlen= ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3334
      inv = ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3335
      Pm_base = ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3336
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3337
                          // Working registers:
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3338
      Ra =  ++reg;        // The current digit of a, b, n, and m.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3339
      Rb =  ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3340
      Rm =  ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3341
      Rn =  ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3342
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3343
      Pa =  ++reg;        // Pointers to the current/next digit of a, b, n, and m.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3344
      Pb =  ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3345
      Pm =  ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3346
      Pn =  ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3347
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3348
      t0 =  ++reg;        // Three registers which form a
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3349
      t1 =  ++reg;        // triple-precision accumuator.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3350
      t2 =  ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3351
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3352
      Ri =  ++reg;        // Inner and outer loop indexes.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3353
      Rj =  ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3354
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3355
      Rhi_ab = ++reg;     // Product registers: low and high parts
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3356
      Rlo_ab = ++reg;     // of a*b and m*n.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3357
      Rhi_mn = ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3358
      Rlo_mn = ++reg;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3359
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3360
      // r19 and up are callee-saved.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3361
      _toSave = RegSet::range(r19, reg) + Pm_base;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3362
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3363
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3364
  private:
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3365
    void save_regs() {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3366
      push(_toSave, sp);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3367
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3368
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3369
    void restore_regs() {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3370
      pop(_toSave, sp);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3371
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3372
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3373
    template <typename T>
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3374
    void unroll_2(Register count, T block) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3375
      Label loop, end, odd;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3376
      tbnz(count, 0, odd);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3377
      cbz(count, end);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3378
      align(16);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3379
      bind(loop);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3380
      (this->*block)();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3381
      bind(odd);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3382
      (this->*block)();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3383
      subs(count, count, 2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3384
      br(Assembler::GT, loop);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3385
      bind(end);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3386
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3387
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3388
    template <typename T>
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3389
    void unroll_2(Register count, T block, Register d, Register s, Register tmp) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3390
      Label loop, end, odd;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3391
      tbnz(count, 0, odd);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3392
      cbz(count, end);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3393
      align(16);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3394
      bind(loop);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3395
      (this->*block)(d, s, tmp);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3396
      bind(odd);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3397
      (this->*block)(d, s, tmp);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3398
      subs(count, count, 2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3399
      br(Assembler::GT, loop);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3400
      bind(end);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3401
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3402
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3403
    void pre1(RegisterOrConstant i) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3404
      block_comment("pre1");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3405
      // Pa = Pa_base;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3406
      // Pb = Pb_base + i;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3407
      // Pm = Pm_base;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3408
      // Pn = Pn_base + i;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3409
      // Ra = *Pa;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3410
      // Rb = *Pb;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3411
      // Rm = *Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3412
      // Rn = *Pn;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3413
      ldr(Ra, Address(Pa_base));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3414
      ldr(Rb, Address(Pb_base, i, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3415
      ldr(Rm, Address(Pm_base));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3416
      ldr(Rn, Address(Pn_base, i, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3417
      lea(Pa, Address(Pa_base));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3418
      lea(Pb, Address(Pb_base, i, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3419
      lea(Pm, Address(Pm_base));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3420
      lea(Pn, Address(Pn_base, i, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3421
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3422
      // Zero the m*n result.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3423
      mov(Rhi_mn, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3424
      mov(Rlo_mn, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3425
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3426
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3427
    // The core multiply-accumulate step of a Montgomery
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3428
    // multiplication.  The idea is to schedule operations as a
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3429
    // pipeline so that instructions with long latencies (loads and
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3430
    // multiplies) have time to complete before their results are
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3431
    // used.  This most benefits in-order implementations of the
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3432
    // architecture but out-of-order ones also benefit.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3433
    void step() {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3434
      block_comment("step");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3435
      // MACC(Ra, Rb, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3436
      // Ra = *++Pa;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3437
      // Rb = *--Pb;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3438
      umulh(Rhi_ab, Ra, Rb);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3439
      mul(Rlo_ab, Ra, Rb);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3440
      ldr(Ra, pre(Pa, wordSize));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3441
      ldr(Rb, pre(Pb, -wordSize));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3442
      acc(Rhi_mn, Rlo_mn, t0, t1, t2); // The pending m*n from the
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3443
                                       // previous iteration.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3444
      // MACC(Rm, Rn, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3445
      // Rm = *++Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3446
      // Rn = *--Pn;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3447
      umulh(Rhi_mn, Rm, Rn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3448
      mul(Rlo_mn, Rm, Rn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3449
      ldr(Rm, pre(Pm, wordSize));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3450
      ldr(Rn, pre(Pn, -wordSize));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3451
      acc(Rhi_ab, Rlo_ab, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3452
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3453
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3454
    void post1() {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3455
      block_comment("post1");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3456
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3457
      // MACC(Ra, Rb, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3458
      // Ra = *++Pa;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3459
      // Rb = *--Pb;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3460
      umulh(Rhi_ab, Ra, Rb);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3461
      mul(Rlo_ab, Ra, Rb);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3462
      acc(Rhi_mn, Rlo_mn, t0, t1, t2);  // The pending m*n
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3463
      acc(Rhi_ab, Rlo_ab, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3464
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3465
      // *Pm = Rm = t0 * inv;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3466
      mul(Rm, t0, inv);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3467
      str(Rm, Address(Pm));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3468
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3469
      // MACC(Rm, Rn, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3470
      // t0 = t1; t1 = t2; t2 = 0;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3471
      umulh(Rhi_mn, Rm, Rn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3472
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3473
#ifndef PRODUCT
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3474
      // assert(m[i] * n[0] + t0 == 0, "broken Montgomery multiply");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3475
      {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3476
        mul(Rlo_mn, Rm, Rn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3477
        add(Rlo_mn, t0, Rlo_mn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3478
        Label ok;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3479
        cbz(Rlo_mn, ok); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3480
          stop("broken Montgomery multiply");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3481
        } bind(ok);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3482
      }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3483
#endif
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3484
      // We have very carefully set things up so that
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3485
      // m[i]*n[0] + t0 == 0 (mod b), so we don't have to calculate
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3486
      // the lower half of Rm * Rn because we know the result already:
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3487
      // it must be -t0.  t0 + (-t0) must generate a carry iff
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3488
      // t0 != 0.  So, rather than do a mul and an adds we just set
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3489
      // the carry flag iff t0 is nonzero.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3490
      //
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3491
      // mul(Rlo_mn, Rm, Rn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3492
      // adds(zr, t0, Rlo_mn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3493
      subs(zr, t0, 1); // Set carry iff t0 is nonzero
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3494
      adcs(t0, t1, Rhi_mn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3495
      adc(t1, t2, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3496
      mov(t2, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3497
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3498
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3499
    void pre2(RegisterOrConstant i, RegisterOrConstant len) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3500
      block_comment("pre2");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3501
      // Pa = Pa_base + i-len;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3502
      // Pb = Pb_base + len;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3503
      // Pm = Pm_base + i-len;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3504
      // Pn = Pn_base + len;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3505
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3506
      if (i.is_register()) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3507
        sub(Rj, i.as_register(), len);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3508
      } else {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3509
        mov(Rj, i.as_constant());
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3510
        sub(Rj, Rj, len);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3511
      }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3512
      // Rj == i-len
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3513
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3514
      lea(Pa, Address(Pa_base, Rj, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3515
      lea(Pb, Address(Pb_base, len, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3516
      lea(Pm, Address(Pm_base, Rj, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3517
      lea(Pn, Address(Pn_base, len, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3518
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3519
      // Ra = *++Pa;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3520
      // Rb = *--Pb;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3521
      // Rm = *++Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3522
      // Rn = *--Pn;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3523
      ldr(Ra, pre(Pa, wordSize));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3524
      ldr(Rb, pre(Pb, -wordSize));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3525
      ldr(Rm, pre(Pm, wordSize));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3526
      ldr(Rn, pre(Pn, -wordSize));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3527
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3528
      mov(Rhi_mn, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3529
      mov(Rlo_mn, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3530
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3531
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3532
    void post2(RegisterOrConstant i, RegisterOrConstant len) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3533
      block_comment("post2");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3534
      if (i.is_constant()) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3535
        mov(Rj, i.as_constant()-len.as_constant());
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3536
      } else {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3537
        sub(Rj, i.as_register(), len);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3538
      }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3539
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3540
      adds(t0, t0, Rlo_mn); // The pending m*n, low part
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3541
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3542
      // As soon as we know the least significant digit of our result,
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3543
      // store it.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3544
      // Pm_base[i-len] = t0;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3545
      str(t0, Address(Pm_base, Rj, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3546
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3547
      // t0 = t1; t1 = t2; t2 = 0;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3548
      adcs(t0, t1, Rhi_mn); // The pending m*n, high part
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3549
      adc(t1, t2, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3550
      mov(t2, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3551
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3552
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3553
    // A carry in t0 after Montgomery multiplication means that we
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3554
    // should subtract multiples of n from our result in m.  We'll
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3555
    // keep doing that until there is no carry.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3556
    void normalize(RegisterOrConstant len) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3557
      block_comment("normalize");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3558
      // while (t0)
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3559
      //   t0 = sub(Pm_base, Pn_base, t0, len);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3560
      Label loop, post, again;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3561
      Register cnt = t1, i = t2; // Re-use registers; we're done with them now
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3562
      cbz(t0, post); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3563
        bind(again); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3564
          mov(i, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3565
          mov(cnt, len);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3566
          ldr(Rm, Address(Pm_base, i, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3567
          ldr(Rn, Address(Pn_base, i, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3568
          subs(zr, zr, zr); // set carry flag, i.e. no borrow
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3569
          align(16);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3570
          bind(loop); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3571
            sbcs(Rm, Rm, Rn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3572
            str(Rm, Address(Pm_base, i, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3573
            add(i, i, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3574
            ldr(Rm, Address(Pm_base, i, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3575
            ldr(Rn, Address(Pn_base, i, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3576
            sub(cnt, cnt, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3577
          } cbnz(cnt, loop);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3578
          sbc(t0, t0, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3579
        } cbnz(t0, again);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3580
      } bind(post);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3581
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3582
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3583
    // Move memory at s to d, reversing words.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3584
    //    Increments d to end of copied memory
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3585
    //    Destroys tmp1, tmp2
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3586
    //    Preserves len
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3587
    //    Leaves s pointing to the address which was in d at start
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3588
    void reverse(Register d, Register s, Register len, Register tmp1, Register tmp2) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3589
      assert(tmp1 < r19 && tmp2 < r19, "register corruption");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3590
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3591
      lea(s, Address(s, len, Address::uxtw(LogBytesPerWord)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3592
      mov(tmp1, len);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3593
      unroll_2(tmp1, &MontgomeryMultiplyGenerator::reverse1, d, s, tmp2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3594
      sub(s, d, len, ext::uxtw, LogBytesPerWord);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3595
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3596
    // where
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3597
    void reverse1(Register d, Register s, Register tmp) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3598
      ldr(tmp, pre(s, -wordSize));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3599
      ror(tmp, tmp, 32);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3600
      str(tmp, post(d, wordSize));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3601
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3602
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3603
    void step_squaring() {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3604
      // An extra ACC
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3605
      step();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3606
      acc(Rhi_ab, Rlo_ab, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3607
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3608
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3609
    void last_squaring(RegisterOrConstant i) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3610
      Label dont;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3611
      // if ((i & 1) == 0) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3612
      tbnz(i.as_register(), 0, dont); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3613
        // MACC(Ra, Rb, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3614
        // Ra = *++Pa;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3615
        // Rb = *--Pb;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3616
        umulh(Rhi_ab, Ra, Rb);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3617
        mul(Rlo_ab, Ra, Rb);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3618
        acc(Rhi_ab, Rlo_ab, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3619
      } bind(dont);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3620
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3621
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3622
    void extra_step_squaring() {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3623
      acc(Rhi_mn, Rlo_mn, t0, t1, t2);  // The pending m*n
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3624
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3625
      // MACC(Rm, Rn, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3626
      // Rm = *++Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3627
      // Rn = *--Pn;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3628
      umulh(Rhi_mn, Rm, Rn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3629
      mul(Rlo_mn, Rm, Rn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3630
      ldr(Rm, pre(Pm, wordSize));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3631
      ldr(Rn, pre(Pn, -wordSize));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3632
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3633
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3634
    void post1_squaring() {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3635
      acc(Rhi_mn, Rlo_mn, t0, t1, t2);  // The pending m*n
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3636
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3637
      // *Pm = Rm = t0 * inv;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3638
      mul(Rm, t0, inv);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3639
      str(Rm, Address(Pm));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3640
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3641
      // MACC(Rm, Rn, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3642
      // t0 = t1; t1 = t2; t2 = 0;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3643
      umulh(Rhi_mn, Rm, Rn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3644
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3645
#ifndef PRODUCT
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3646
      // assert(m[i] * n[0] + t0 == 0, "broken Montgomery multiply");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3647
      {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3648
        mul(Rlo_mn, Rm, Rn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3649
        add(Rlo_mn, t0, Rlo_mn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3650
        Label ok;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3651
        cbz(Rlo_mn, ok); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3652
          stop("broken Montgomery multiply");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3653
        } bind(ok);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3654
      }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3655
#endif
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3656
      // We have very carefully set things up so that
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3657
      // m[i]*n[0] + t0 == 0 (mod b), so we don't have to calculate
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3658
      // the lower half of Rm * Rn because we know the result already:
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3659
      // it must be -t0.  t0 + (-t0) must generate a carry iff
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3660
      // t0 != 0.  So, rather than do a mul and an adds we just set
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3661
      // the carry flag iff t0 is nonzero.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3662
      //
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3663
      // mul(Rlo_mn, Rm, Rn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3664
      // adds(zr, t0, Rlo_mn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3665
      subs(zr, t0, 1); // Set carry iff t0 is nonzero
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3666
      adcs(t0, t1, Rhi_mn);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3667
      adc(t1, t2, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3668
      mov(t2, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3669
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3670
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3671
    void acc(Register Rhi, Register Rlo,
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3672
             Register t0, Register t1, Register t2) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3673
      adds(t0, t0, Rlo);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3674
      adcs(t1, t1, Rhi);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3675
      adc(t2, t2, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3676
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3677
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3678
  public:
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3679
    /**
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3680
     * Fast Montgomery multiplication.  The derivation of the
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3681
     * algorithm is in A Cryptographic Library for the Motorola
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3682
     * DSP56000, Dusse and Kaliski, Proc. EUROCRYPT 90, pp. 230-237.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3683
     *
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3684
     * Arguments:
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3685
     *
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3686
     * Inputs for multiplication:
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3687
     *   c_rarg0   - int array elements a
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3688
     *   c_rarg1   - int array elements b
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3689
     *   c_rarg2   - int array elements n (the modulus)
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3690
     *   c_rarg3   - int length
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3691
     *   c_rarg4   - int inv
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3692
     *   c_rarg5   - int array elements m (the result)
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3693
     *
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3694
     * Inputs for squaring:
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3695
     *   c_rarg0   - int array elements a
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3696
     *   c_rarg1   - int array elements n (the modulus)
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3697
     *   c_rarg2   - int length
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3698
     *   c_rarg3   - int inv
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3699
     *   c_rarg4   - int array elements m (the result)
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3700
     *
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3701
     */
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3702
    address generate_multiply() {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3703
      Label argh, nothing;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3704
      bind(argh);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3705
      stop("MontgomeryMultiply total_allocation must be <= 8192");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3706
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3707
      align(CodeEntryAlignment);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3708
      address entry = pc();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3709
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3710
      cbzw(Rlen, nothing);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3711
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3712
      enter();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3713
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3714
      // Make room.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3715
      cmpw(Rlen, 512);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3716
      br(Assembler::HI, argh);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3717
      sub(Ra, sp, Rlen, ext::uxtw, exact_log2(4 * sizeof (jint)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3718
      andr(sp, Ra, -2 * wordSize);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3719
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3720
      lsrw(Rlen, Rlen, 1);  // length in longwords = len/2
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3721
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3722
      {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3723
        // Copy input args, reversing as we go.  We use Ra as a
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3724
        // temporary variable.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3725
        reverse(Ra, Pa_base, Rlen, t0, t1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3726
        if (!_squaring)
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3727
          reverse(Ra, Pb_base, Rlen, t0, t1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3728
        reverse(Ra, Pn_base, Rlen, t0, t1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3729
      }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3730
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3731
      // Push all call-saved registers and also Pm_base which we'll need
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3732
      // at the end.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3733
      save_regs();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3734
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3735
#ifndef PRODUCT
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3736
      // assert(inv * n[0] == -1UL, "broken inverse in Montgomery multiply");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3737
      {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3738
        ldr(Rn, Address(Pn_base, 0));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3739
        mul(Rlo_mn, Rn, inv);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3740
        cmp(Rlo_mn, -1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3741
        Label ok;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3742
        br(EQ, ok); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3743
          stop("broken inverse in Montgomery multiply");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3744
        } bind(ok);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3745
      }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3746
#endif
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3747
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3748
      mov(Pm_base, Ra);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3749
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3750
      mov(t0, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3751
      mov(t1, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3752
      mov(t2, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3753
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3754
      block_comment("for (int i = 0; i < len; i++) {");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3755
      mov(Ri, zr); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3756
        Label loop, end;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3757
        cmpw(Ri, Rlen);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3758
        br(Assembler::GE, end);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3759
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3760
        bind(loop);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3761
        pre1(Ri);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3762
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3763
        block_comment("  for (j = i; j; j--) {"); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3764
          movw(Rj, Ri);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3765
          unroll_2(Rj, &MontgomeryMultiplyGenerator::step);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3766
        } block_comment("  } // j");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3767
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3768
        post1();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3769
        addw(Ri, Ri, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3770
        cmpw(Ri, Rlen);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3771
        br(Assembler::LT, loop);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3772
        bind(end);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3773
        block_comment("} // i");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3774
      }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3775
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3776
      block_comment("for (int i = len; i < 2*len; i++) {");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3777
      mov(Ri, Rlen); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3778
        Label loop, end;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3779
        cmpw(Ri, Rlen, Assembler::LSL, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3780
        br(Assembler::GE, end);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3781
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3782
        bind(loop);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3783
        pre2(Ri, Rlen);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3784
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3785
        block_comment("  for (j = len*2-i-1; j; j--) {"); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3786
          lslw(Rj, Rlen, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3787
          subw(Rj, Rj, Ri);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3788
          subw(Rj, Rj, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3789
          unroll_2(Rj, &MontgomeryMultiplyGenerator::step);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3790
        } block_comment("  } // j");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3791
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3792
        post2(Ri, Rlen);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3793
        addw(Ri, Ri, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3794
        cmpw(Ri, Rlen, Assembler::LSL, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3795
        br(Assembler::LT, loop);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3796
        bind(end);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3797
      }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3798
      block_comment("} // i");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3799
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3800
      normalize(Rlen);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3801
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3802
      mov(Ra, Pm_base);  // Save Pm_base in Ra
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3803
      restore_regs();  // Restore caller's Pm_base
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3804
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3805
      // Copy our result into caller's Pm_base
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3806
      reverse(Pm_base, Ra, Rlen, t0, t1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3807
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3808
      leave();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3809
      bind(nothing);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3810
      ret(lr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3811
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3812
      return entry;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3813
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3814
    // In C, approximately:
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3815
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3816
    // void
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3817
    // montgomery_multiply(unsigned long Pa_base[], unsigned long Pb_base[],
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3818
    //                     unsigned long Pn_base[], unsigned long Pm_base[],
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3819
    //                     unsigned long inv, int len) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3820
    //   unsigned long t0 = 0, t1 = 0, t2 = 0; // Triple-precision accumulator
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3821
    //   unsigned long *Pa, *Pb, *Pn, *Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3822
    //   unsigned long Ra, Rb, Rn, Rm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3823
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3824
    //   int i;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3825
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3826
    //   assert(inv * Pn_base[0] == -1UL, "broken inverse in Montgomery multiply");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3827
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3828
    //   for (i = 0; i < len; i++) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3829
    //     int j;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3830
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3831
    //     Pa = Pa_base;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3832
    //     Pb = Pb_base + i;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3833
    //     Pm = Pm_base;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3834
    //     Pn = Pn_base + i;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3835
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3836
    //     Ra = *Pa;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3837
    //     Rb = *Pb;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3838
    //     Rm = *Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3839
    //     Rn = *Pn;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3840
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3841
    //     int iters = i;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3842
    //     for (j = 0; iters--; j++) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3843
    //       assert(Ra == Pa_base[j] && Rb == Pb_base[i-j], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3844
    //       MACC(Ra, Rb, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3845
    //       Ra = *++Pa;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3846
    //       Rb = *--Pb;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3847
    //       assert(Rm == Pm_base[j] && Rn == Pn_base[i-j], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3848
    //       MACC(Rm, Rn, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3849
    //       Rm = *++Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3850
    //       Rn = *--Pn;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3851
    //     }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3852
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3853
    //     assert(Ra == Pa_base[i] && Rb == Pb_base[0], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3854
    //     MACC(Ra, Rb, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3855
    //     *Pm = Rm = t0 * inv;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3856
    //     assert(Rm == Pm_base[i] && Rn == Pn_base[0], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3857
    //     MACC(Rm, Rn, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3858
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3859
    //     assert(t0 == 0, "broken Montgomery multiply");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3860
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3861
    //     t0 = t1; t1 = t2; t2 = 0;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3862
    //   }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3863
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3864
    //   for (i = len; i < 2*len; i++) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3865
    //     int j;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3866
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3867
    //     Pa = Pa_base + i-len;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3868
    //     Pb = Pb_base + len;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3869
    //     Pm = Pm_base + i-len;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3870
    //     Pn = Pn_base + len;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3871
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3872
    //     Ra = *++Pa;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3873
    //     Rb = *--Pb;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3874
    //     Rm = *++Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3875
    //     Rn = *--Pn;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3876
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3877
    //     int iters = len*2-i-1;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3878
    //     for (j = i-len+1; iters--; j++) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3879
    //       assert(Ra == Pa_base[j] && Rb == Pb_base[i-j], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3880
    //       MACC(Ra, Rb, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3881
    //       Ra = *++Pa;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3882
    //       Rb = *--Pb;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3883
    //       assert(Rm == Pm_base[j] && Rn == Pn_base[i-j], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3884
    //       MACC(Rm, Rn, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3885
    //       Rm = *++Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3886
    //       Rn = *--Pn;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3887
    //     }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3888
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3889
    //     Pm_base[i-len] = t0;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3890
    //     t0 = t1; t1 = t2; t2 = 0;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3891
    //   }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3892
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3893
    //   while (t0)
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3894
    //     t0 = sub(Pm_base, Pn_base, t0, len);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3895
    // }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3896
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3897
    /**
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3898
     * Fast Montgomery squaring.  This uses asymptotically 25% fewer
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3899
     * multiplies than Montgomery multiplication so it should be up to
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3900
     * 25% faster.  However, its loop control is more complex and it
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3901
     * may actually run slower on some machines.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3902
     *
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3903
     * Arguments:
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3904
     *
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3905
     * Inputs:
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3906
     *   c_rarg0   - int array elements a
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3907
     *   c_rarg1   - int array elements n (the modulus)
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3908
     *   c_rarg2   - int length
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3909
     *   c_rarg3   - int inv
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3910
     *   c_rarg4   - int array elements m (the result)
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3911
     *
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3912
     */
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3913
    address generate_square() {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3914
      Label argh;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3915
      bind(argh);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3916
      stop("MontgomeryMultiply total_allocation must be <= 8192");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3917
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3918
      align(CodeEntryAlignment);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3919
      address entry = pc();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3920
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3921
      enter();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3922
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3923
      // Make room.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3924
      cmpw(Rlen, 512);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3925
      br(Assembler::HI, argh);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3926
      sub(Ra, sp, Rlen, ext::uxtw, exact_log2(4 * sizeof (jint)));
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3927
      andr(sp, Ra, -2 * wordSize);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3928
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3929
      lsrw(Rlen, Rlen, 1);  // length in longwords = len/2
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3930
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3931
      {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3932
        // Copy input args, reversing as we go.  We use Ra as a
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3933
        // temporary variable.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3934
        reverse(Ra, Pa_base, Rlen, t0, t1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3935
        reverse(Ra, Pn_base, Rlen, t0, t1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3936
      }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3937
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3938
      // Push all call-saved registers and also Pm_base which we'll need
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3939
      // at the end.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3940
      save_regs();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3941
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3942
      mov(Pm_base, Ra);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3943
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3944
      mov(t0, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3945
      mov(t1, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3946
      mov(t2, zr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3947
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3948
      block_comment("for (int i = 0; i < len; i++) {");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3949
      mov(Ri, zr); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3950
        Label loop, end;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3951
        bind(loop);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3952
        cmp(Ri, Rlen);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3953
        br(Assembler::GE, end);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3954
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3955
        pre1(Ri);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3956
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3957
        block_comment("for (j = (i+1)/2; j; j--) {"); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3958
          add(Rj, Ri, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3959
          lsr(Rj, Rj, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3960
          unroll_2(Rj, &MontgomeryMultiplyGenerator::step_squaring);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3961
        } block_comment("  } // j");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3962
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3963
        last_squaring(Ri);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3964
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3965
        block_comment("  for (j = i/2; j; j--) {"); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3966
          lsr(Rj, Ri, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3967
          unroll_2(Rj, &MontgomeryMultiplyGenerator::extra_step_squaring);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3968
        } block_comment("  } // j");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3969
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3970
        post1_squaring();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3971
        add(Ri, Ri, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3972
        cmp(Ri, Rlen);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3973
        br(Assembler::LT, loop);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3974
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3975
        bind(end);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3976
        block_comment("} // i");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3977
      }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3978
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3979
      block_comment("for (int i = len; i < 2*len; i++) {");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3980
      mov(Ri, Rlen); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3981
        Label loop, end;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3982
        bind(loop);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3983
        cmp(Ri, Rlen, Assembler::LSL, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3984
        br(Assembler::GE, end);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3985
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3986
        pre2(Ri, Rlen);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3987
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3988
        block_comment("  for (j = (2*len-i-1)/2; j; j--) {"); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3989
          lsl(Rj, Rlen, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3990
          sub(Rj, Rj, Ri);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3991
          sub(Rj, Rj, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3992
          lsr(Rj, Rj, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3993
          unroll_2(Rj, &MontgomeryMultiplyGenerator::step_squaring);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3994
        } block_comment("  } // j");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3995
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3996
        last_squaring(Ri);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3997
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3998
        block_comment("  for (j = (2*len-i)/2; j; j--) {"); {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  3999
          lsl(Rj, Rlen, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4000
          sub(Rj, Rj, Ri);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4001
          lsr(Rj, Rj, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4002
          unroll_2(Rj, &MontgomeryMultiplyGenerator::extra_step_squaring);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4003
        } block_comment("  } // j");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4004
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4005
        post2(Ri, Rlen);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4006
        add(Ri, Ri, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4007
        cmp(Ri, Rlen, Assembler::LSL, 1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4008
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4009
        br(Assembler::LT, loop);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4010
        bind(end);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4011
        block_comment("} // i");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4012
      }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4013
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4014
      normalize(Rlen);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4015
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4016
      mov(Ra, Pm_base);  // Save Pm_base in Ra
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4017
      restore_regs();  // Restore caller's Pm_base
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4018
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4019
      // Copy our result into caller's Pm_base
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4020
      reverse(Pm_base, Ra, Rlen, t0, t1);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4021
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4022
      leave();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4023
      ret(lr);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4024
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4025
      return entry;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4026
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4027
    // In C, approximately:
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4028
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4029
    // void
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4030
    // montgomery_square(unsigned long Pa_base[], unsigned long Pn_base[],
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4031
    //                   unsigned long Pm_base[], unsigned long inv, int len) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4032
    //   unsigned long t0 = 0, t1 = 0, t2 = 0; // Triple-precision accumulator
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4033
    //   unsigned long *Pa, *Pb, *Pn, *Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4034
    //   unsigned long Ra, Rb, Rn, Rm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4035
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4036
    //   int i;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4037
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4038
    //   assert(inv * Pn_base[0] == -1UL, "broken inverse in Montgomery multiply");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4039
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4040
    //   for (i = 0; i < len; i++) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4041
    //     int j;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4042
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4043
    //     Pa = Pa_base;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4044
    //     Pb = Pa_base + i;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4045
    //     Pm = Pm_base;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4046
    //     Pn = Pn_base + i;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4047
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4048
    //     Ra = *Pa;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4049
    //     Rb = *Pb;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4050
    //     Rm = *Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4051
    //     Rn = *Pn;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4052
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4053
    //     int iters = (i+1)/2;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4054
    //     for (j = 0; iters--; j++) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4055
    //       assert(Ra == Pa_base[j] && Rb == Pa_base[i-j], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4056
    //       MACC2(Ra, Rb, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4057
    //       Ra = *++Pa;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4058
    //       Rb = *--Pb;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4059
    //       assert(Rm == Pm_base[j] && Rn == Pn_base[i-j], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4060
    //       MACC(Rm, Rn, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4061
    //       Rm = *++Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4062
    //       Rn = *--Pn;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4063
    //     }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4064
    //     if ((i & 1) == 0) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4065
    //       assert(Ra == Pa_base[j], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4066
    //       MACC(Ra, Ra, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4067
    //     }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4068
    //     iters = i/2;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4069
    //     assert(iters == i-j, "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4070
    //     for (; iters--; j++) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4071
    //       assert(Rm == Pm_base[j] && Rn == Pn_base[i-j], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4072
    //       MACC(Rm, Rn, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4073
    //       Rm = *++Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4074
    //       Rn = *--Pn;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4075
    //     }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4076
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4077
    //     *Pm = Rm = t0 * inv;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4078
    //     assert(Rm == Pm_base[i] && Rn == Pn_base[0], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4079
    //     MACC(Rm, Rn, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4080
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4081
    //     assert(t0 == 0, "broken Montgomery multiply");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4082
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4083
    //     t0 = t1; t1 = t2; t2 = 0;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4084
    //   }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4085
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4086
    //   for (i = len; i < 2*len; i++) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4087
    //     int start = i-len+1;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4088
    //     int end = start + (len - start)/2;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4089
    //     int j;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4090
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4091
    //     Pa = Pa_base + i-len;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4092
    //     Pb = Pa_base + len;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4093
    //     Pm = Pm_base + i-len;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4094
    //     Pn = Pn_base + len;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4095
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4096
    //     Ra = *++Pa;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4097
    //     Rb = *--Pb;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4098
    //     Rm = *++Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4099
    //     Rn = *--Pn;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4100
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4101
    //     int iters = (2*len-i-1)/2;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4102
    //     assert(iters == end-start, "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4103
    //     for (j = start; iters--; j++) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4104
    //       assert(Ra == Pa_base[j] && Rb == Pa_base[i-j], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4105
    //       MACC2(Ra, Rb, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4106
    //       Ra = *++Pa;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4107
    //       Rb = *--Pb;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4108
    //       assert(Rm == Pm_base[j] && Rn == Pn_base[i-j], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4109
    //       MACC(Rm, Rn, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4110
    //       Rm = *++Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4111
    //       Rn = *--Pn;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4112
    //     }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4113
    //     if ((i & 1) == 0) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4114
    //       assert(Ra == Pa_base[j], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4115
    //       MACC(Ra, Ra, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4116
    //     }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4117
    //     iters =  (2*len-i)/2;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4118
    //     assert(iters == len-j, "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4119
    //     for (; iters--; j++) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4120
    //       assert(Rm == Pm_base[j] && Rn == Pn_base[i-j], "must be");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4121
    //       MACC(Rm, Rn, t0, t1, t2);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4122
    //       Rm = *++Pm;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4123
    //       Rn = *--Pn;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4124
    //     }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4125
    //     Pm_base[i-len] = t0;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4126
    //     t0 = t1; t1 = t2; t2 = 0;
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4127
    //   }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4128
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4129
    //   while (t0)
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4130
    //     t0 = sub(Pm_base, Pn_base, t0, len);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4131
    // }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4132
  };
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4133
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4134
  // Initialization
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4135
  void generate_initial() {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4136
    // Generate initial stubs and initializes the entry points
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4137
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4138
    // entry points that exist in all platforms Note: This is code
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4139
    // that could be shared among different platforms - however the
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4140
    // benefit seems to be smaller than the disadvantage of having a
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4141
    // much more complicated generator structure. See also comment in
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4142
    // stubRoutines.hpp.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4143
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4144
    StubRoutines::_forward_exception_entry = generate_forward_exception();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4145
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4146
    StubRoutines::_call_stub_entry =
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4147
      generate_call_stub(StubRoutines::_call_stub_return_address);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4148
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4149
    // is referenced by megamorphic call
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4150
    StubRoutines::_catch_exception_entry = generate_catch_exception();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4151
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4152
    // Build this early so it's available for the interpreter.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4153
    StubRoutines::_throw_StackOverflowError_entry =
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4154
      generate_throw_exception("StackOverflowError throw_exception",
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4155
                               CAST_FROM_FN_PTR(address,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4156
                                                SharedRuntime::
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4157
                                                throw_StackOverflowError));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4158
    if (UseCRC32Intrinsics) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4159
      // set table address before stub generation which use it
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4160
      StubRoutines::_crc_table_adr = (address)StubRoutines::aarch64::_crc_table;
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4161
      StubRoutines::_updateBytesCRC32 = generate_updateBytesCRC32();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4162
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4163
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4164
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4165
  void generate_all() {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4166
    // support for verify_oop (must happen after universe_init)
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4167
    StubRoutines::_verify_oop_subroutine_entry     = generate_verify_oop();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4168
    StubRoutines::_throw_AbstractMethodError_entry =
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4169
      generate_throw_exception("AbstractMethodError throw_exception",
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4170
                               CAST_FROM_FN_PTR(address,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4171
                                                SharedRuntime::
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4172
                                                throw_AbstractMethodError));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4173
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4174
    StubRoutines::_throw_IncompatibleClassChangeError_entry =
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4175
      generate_throw_exception("IncompatibleClassChangeError throw_exception",
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4176
                               CAST_FROM_FN_PTR(address,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4177
                                                SharedRuntime::
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4178
                                                throw_IncompatibleClassChangeError));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4179
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4180
    StubRoutines::_throw_NullPointerException_at_call_entry =
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4181
      generate_throw_exception("NullPointerException at call throw_exception",
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4182
                               CAST_FROM_FN_PTR(address,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4183
                                                SharedRuntime::
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4184
                                                throw_NullPointerException_at_call));
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4185
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4186
    // arraycopy stubs used by compilers
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4187
    generate_arraycopy_stubs();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4188
30225
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  4189
    if (UseMultiplyToLenIntrinsic) {
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  4190
      StubRoutines::_multiplyToLen = generate_multiplyToLen();
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  4191
    }
e9722ea461d4 8077615: AARCH64: Add C2 intrinsic for BigInteger::multiplyToLen() method
aph
parents: 29695
diff changeset
  4192
31955
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4193
    if (UseMontgomeryMultiplyIntrinsic) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4194
      StubCodeMark mark(this, "StubRoutines", "montgomeryMultiply");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4195
      MontgomeryMultiplyGenerator g(_masm, /*squaring*/false);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4196
      StubRoutines::_montgomeryMultiply = g.generate_multiply();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4197
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4198
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4199
    if (UseMontgomerySquareIntrinsic) {
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4200
      StubCodeMark mark(this, "StubRoutines", "montgomerySquare");
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4201
      MontgomeryMultiplyGenerator g(_masm, /*squaring*/true);
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4202
      // We use generate_multiply() rather than generate_square()
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4203
      // because it's faster for the sizes of modulus we care about.
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4204
      StubRoutines::_montgomerySquare = g.generate_multiply();
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4205
    }
c6ac18ab3d6b 8131779: AARCH64: add Montgomery multiply intrinsic
aph
parents: 31591
diff changeset
  4206
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4207
#ifndef BUILTIN_SIM
31961
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  4208
    // generate GHASH intrinsics code
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  4209
    if (UseGHASHIntrinsics) {
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  4210
      StubRoutines::_ghash_processBlocks = generate_ghash_processBlocks();
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  4211
    }
70adcff5840c 8131062: aarch64: add support for GHASH acceleration
enevill
parents: 31955
diff changeset
  4212
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4213
    if (UseAESIntrinsics) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4214
      StubRoutines::_aescrypt_encryptBlock = generate_aescrypt_encryptBlock();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4215
      StubRoutines::_aescrypt_decryptBlock = generate_aescrypt_decryptBlock();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4216
      StubRoutines::_cipherBlockChaining_encryptAESCrypt = generate_cipherBlockChaining_encryptAESCrypt();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4217
      StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4218
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4219
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4220
    if (UseSHA1Intrinsics) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4221
      StubRoutines::_sha1_implCompress     = generate_sha1_implCompress(false,   "sha1_implCompress");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4222
      StubRoutines::_sha1_implCompressMB   = generate_sha1_implCompress(true,    "sha1_implCompressMB");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4223
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4224
    if (UseSHA256Intrinsics) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4225
      StubRoutines::_sha256_implCompress   = generate_sha256_implCompress(false, "sha256_implCompress");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4226
      StubRoutines::_sha256_implCompressMB = generate_sha256_implCompress(true,  "sha256_implCompressMB");
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4227
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4228
31591
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  4229
    if (UseCRC32CIntrinsics) {
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  4230
      StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C();
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  4231
    }
82134a118aea 8130687: aarch64: add support for hardware crc32c
enevill
parents: 30553
diff changeset
  4232
33176
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  4233
    // generate Adler32 intrinsics code
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  4234
    if (UseAdler32Intrinsics) {
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  4235
      StubRoutines::_updateBytesAdler32 = generate_updateBytesAdler32();
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  4236
    }
54393049bf1e 8139043: aarch64: add support for adler32 intrinsic
enevill
parents: 32627
diff changeset
  4237
29183
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4238
    // Safefetch stubs.
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4239
    generate_safefetch("SafeFetch32", sizeof(int),     &StubRoutines::_safefetch32_entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4240
                                                       &StubRoutines::_safefetch32_fault_pc,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4241
                                                       &StubRoutines::_safefetch32_continuation_pc);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4242
    generate_safefetch("SafeFetchN", sizeof(intptr_t), &StubRoutines::_safefetchN_entry,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4243
                                                       &StubRoutines::_safefetchN_fault_pc,
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4244
                                                       &StubRoutines::_safefetchN_continuation_pc);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4245
#endif
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4246
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4247
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4248
 public:
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4249
  StubGenerator(CodeBuffer* code, bool all) : StubCodeGenerator(code) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4250
    if (all) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4251
      generate_all();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4252
    } else {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4253
      generate_initial();
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4254
    }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4255
  }
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4256
}; // end class declaration
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4257
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4258
void StubGenerator_generate(CodeBuffer* code, bool all) {
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4259
  StubGenerator g(code, all);
0cc8699f7372 8068054: AARCH64: Assembler interpreter, shared runtime
aph
parents:
diff changeset
  4260
}