src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58462 c6f1226cfb72
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53546
63eb7e38ce84 8217922: Compiler dead code removal
redestad
parents: 52990
diff changeset
     2
 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5419
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5419
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5419
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    25
#include "precompiled.hpp"
14626
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 14132
diff changeset
    26
#include "asm/macroAssembler.hpp"
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 14132
diff changeset
    27
#include "asm/macroAssembler.inline.hpp"
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48807
diff changeset
    28
#include "ci/ciUtilities.hpp"
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    29
#include "gc/shared/barrierSet.hpp"
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    30
#include "gc/shared/barrierSetAssembler.hpp"
52142
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
    31
#include "gc/shared/barrierSetNMethod.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    32
#include "interpreter/interpreter.hpp"
54786
ebf733a324d4 8223624: Cleanup includes of universe.hpp
stefank
parents: 54755
diff changeset
    33
#include "memory/universe.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    34
#include "nativeInst_x86.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    35
#include "oops/instanceOop.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    36
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    37
#include "oops/objArrayKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    38
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    39
#include "prims/methodHandles.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    40
#include "runtime/frame.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    41
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    42
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    43
#include "runtime/stubCodeGenerator.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    44
#include "runtime/stubRoutines.hpp"
14583
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents: 14132
diff changeset
    45
#include "runtime/thread.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    46
#ifdef COMPILER2
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    47
#include "opto/runtime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6433
diff changeset
    48
#endif
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50179
diff changeset
    49
#if INCLUDE_ZGC
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50179
diff changeset
    50
#include "gc/z/zThreadLocalData.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50179
diff changeset
    51
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// Declaration and definition of StubGenerator (no .hpp file).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
// For a more detailed description of the stub routine structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// see the comment in stubRoutines.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
#define __ _masm->
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
    58
#define TIMES_OOP (UseCompressedOops ? Address::times_4 : Address::times_8)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
    59
#define a__ ((Assembler*)_masm)->
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
#ifdef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
#define BLOCK_COMMENT(str) /* nothing */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
#define BLOCK_COMMENT(str) __ block_comment(str)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
const int MXCSR_MASK = 0xFFC0;  // Mask out any pending exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// Stub Code definitions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
class StubGenerator: public StubCodeGenerator {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
#ifdef PRODUCT
18073
f02460441ddc 8014431: cleanup warnings indicated by the -Wunused-value compiler option on linux
ccheung
parents: 17622
diff changeset
    76
#define inc_counter_np(counter) ((void)0)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  void inc_counter_np_(int& counter) {
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
    79
    // This can destroy rscratch1 if counter is far from the code cache
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    __ incrementl(ExternalAddress((address)&counter));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
#define inc_counter_np(counter) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  BLOCK_COMMENT("inc_counter " #counter); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  inc_counter_np_(counter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // Call stubs are used to call Java from C
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // Linux Arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  //    c_rarg0:   call wrapper address                   address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  //    c_rarg1:   result                                 address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  //    c_rarg2:   result type                            BasicType
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    93
  //    c_rarg3:   method                                 Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  //    c_rarg4:   (interpreter) entry point              address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  //    c_rarg5:   parameters                             intptr_t*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  //    16(rbp): parameter size (in words)              int
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  //    24(rbp): thread                                 Thread*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  //     [ return_from_Java     ] <--- rsp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  //     [ argument word n      ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  //      ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // -12 [ argument word 1      ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // -11 [ saved r15            ] <--- rsp_after_call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // -10 [ saved r14            ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  //  -9 [ saved r13            ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  //  -8 [ saved r12            ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  //  -7 [ saved rbx            ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  //  -6 [ call wrapper         ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  //  -5 [ result               ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  //  -4 [ result type          ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  //  -3 [ method               ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  //  -2 [ entry point          ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  //  -1 [ parameters           ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  //   0 [ saved rbp            ] <--- rbp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  //   1 [ return address       ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  //   2 [ parameter size       ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  //   3 [ thread               ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  // Windows Arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  //    c_rarg0:   call wrapper address                   address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  //    c_rarg1:   result                                 address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  //    c_rarg2:   result type                            BasicType
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   123
  //    c_rarg3:   method                                 Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  //    48(rbp): (interpreter) entry point              address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  //    56(rbp): parameters                             intptr_t*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  //    64(rbp): parameter size (in words)              int
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  //    72(rbp): thread                                 Thread*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  //     [ return_from_Java     ] <--- rsp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  //     [ argument word n      ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  //      ...
30624
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30299
diff changeset
   132
  // -60 [ argument word 1      ]
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30299
diff changeset
   133
  // -59 [ saved xmm31          ] <--- rsp after_call
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30299
diff changeset
   134
  //     [ saved xmm16-xmm30    ] (EVEX enabled, else the space is blank)
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30299
diff changeset
   135
  // -27 [ saved xmm15          ]
8874
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   136
  //     [ saved xmm7-xmm14     ]
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   137
  //  -9 [ saved xmm6           ] (each xmm register takes 2 slots)
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   138
  //  -7 [ saved r15            ]
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  //  -6 [ saved r14            ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  //  -5 [ saved r13            ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  //  -4 [ saved r12            ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  //  -3 [ saved rdi            ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  //  -2 [ saved rsi            ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  //  -1 [ saved rbx            ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  //   0 [ saved rbp            ] <--- rbp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  //   1 [ return address       ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  //   2 [ call wrapper         ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  //   3 [ result               ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  //   4 [ result type          ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  //   5 [ method               ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  //   6 [ entry point          ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  //   7 [ parameters           ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  //   8 [ parameter size       ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  //   9 [ thread               ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  //    Windows reserves the callers stack space for arguments 1-4.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  //    We spill c_rarg0-c_rarg3 to this space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  // Call stub stack layout word offsets from rbp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  enum call_stub_layout {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
#ifdef _WIN64
8874
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   162
    xmm_save_first     = 6,  // save from xmm6
30624
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30299
diff changeset
   163
    xmm_save_last      = 31, // to xmm31
8874
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   164
    xmm_save_base      = -9,
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   165
    rsp_after_call_off = xmm_save_base - 2 * (xmm_save_last - xmm_save_first), // -27
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   166
    r15_off            = -7,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    r14_off            = -6,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    r13_off            = -5,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    r12_off            = -4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    rdi_off            = -3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    rsi_off            = -2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    rbx_off            = -1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    rbp_off            =  0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    retaddr_off        =  1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    call_wrapper_off   =  2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    result_off         =  3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    result_type_off    =  4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    method_off         =  5,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    entry_point_off    =  6,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    parameters_off     =  7,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    parameter_size_off =  8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    thread_off         =  9
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    rsp_after_call_off = -12,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    mxcsr_off          = rsp_after_call_off,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
    r15_off            = -11,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    r14_off            = -10,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    r13_off            = -9,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    r12_off            = -8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    rbx_off            = -7,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    call_wrapper_off   = -6,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    result_off         = -5,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    result_type_off    = -4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
    method_off         = -3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    entry_point_off    = -2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    parameters_off     = -1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    rbp_off            =  0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    retaddr_off        =  1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    parameter_size_off =  2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    thread_off         =  3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
8874
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   204
#ifdef _WIN64
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   205
  Address xmm_save(int reg) {
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   206
    assert(reg >= xmm_save_first && reg <= xmm_save_last, "XMM register number out of range");
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   207
    return Address(rbp, (xmm_save_base - (reg - xmm_save_first) * 2) * wordSize);
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   208
  }
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   209
#endif
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   210
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  address generate_call_stub(address& return_address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    assert((int)frame::entry_frame_after_call_words == -(int)rsp_after_call_off + 1 &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
           (int)frame::entry_frame_call_wrapper_offset == (int)call_wrapper_off,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
           "adjust this code");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    StubCodeMark mark(this, "StubRoutines", "call_stub");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    // same as in generate_catch_exception()!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    const Address rsp_after_call(rbp, rsp_after_call_off * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    const Address call_wrapper  (rbp, call_wrapper_off   * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
    const Address result        (rbp, result_off         * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    const Address result_type   (rbp, result_type_off    * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    const Address method        (rbp, method_off         * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
    const Address entry_point   (rbp, entry_point_off    * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    const Address parameters    (rbp, parameters_off     * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    const Address parameter_size(rbp, parameter_size_off * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    // same as in generate_catch_exception()!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
    const Address thread        (rbp, thread_off         * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    const Address r15_save(rbp, r15_off * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    const Address r14_save(rbp, r14_off * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    const Address r13_save(rbp, r13_off * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    const Address r12_save(rbp, r12_off * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    const Address rbx_save(rbp, rbx_off * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    // stub code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    __ enter();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   240
    __ subptr(rsp, -rsp_after_call_off * wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    // save register parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
#ifndef _WIN64
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   244
    __ movptr(parameters,   c_rarg5); // parameters
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   245
    __ movptr(entry_point,  c_rarg4); // entry_point
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   248
    __ movptr(method,       c_rarg3); // method
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   249
    __ movl(result_type,  c_rarg2);   // result type
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   250
    __ movptr(result,       c_rarg1); // result
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   251
    __ movptr(call_wrapper, c_rarg0); // call wrapper
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    // save regs belonging to calling function
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   254
    __ movptr(rbx_save, rbx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   255
    __ movptr(r12_save, r12);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   256
    __ movptr(r13_save, r13);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   257
    __ movptr(r14_save, r14);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   258
    __ movptr(r15_save, r15);
51976
390f529f4f22 8211251: Default mask register for avx512 instructions
kvn
parents: 51784
diff changeset
   259
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
#ifdef _WIN64
32727
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32596
diff changeset
   261
    int last_reg = 15;
30624
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30299
diff changeset
   262
    if (UseAVX > 2) {
32727
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32596
diff changeset
   263
      last_reg = 31;
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32596
diff changeset
   264
    }
34162
16b54851eaf6 8140779: Code generation fixes for avx512
iveresov
parents: 33465
diff changeset
   265
    if (VM_Version::supports_evex()) {
32727
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32596
diff changeset
   266
      for (int i = xmm_save_first; i <= last_reg; i++) {
36561
b18243f4d955 8151002: Make Assembler methods vextract and vinsert match actual instructions
mikael
parents: 36555
diff changeset
   267
        __ vextractf32x4(xmm_save(i), as_XMMRegister(i), 0);
30624
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30299
diff changeset
   268
      }
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30299
diff changeset
   269
    } else {
32727
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32596
diff changeset
   270
      for (int i = xmm_save_first; i <= last_reg; i++) {
30624
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30299
diff changeset
   271
        __ movdqu(xmm_save(i), as_XMMRegister(i));
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30299
diff changeset
   272
      }
8874
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   273
    }
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   274
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    const Address rdi_save(rbp, rdi_off * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    const Address rsi_save(rbp, rsi_off * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   278
    __ movptr(rsi_save, rsi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   279
    __ movptr(rdi_save, rdi);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    const Address mxcsr_save(rbp, mxcsr_off * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
      Label skip_ldmx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
      __ stmxcsr(mxcsr_save);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
      __ movl(rax, mxcsr_save);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
      __ andl(rax, MXCSR_MASK);    // Only check control and mask bits
18958
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
   287
      ExternalAddress mxcsr_std(StubRoutines::addr_mxcsr_std());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
      __ cmp32(rax, mxcsr_std);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
      __ jcc(Assembler::equal, skip_ldmx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
      __ ldmxcsr(mxcsr_std);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
      __ bind(skip_ldmx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
    // Load up thread register
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   296
    __ movptr(r15_thread, thread);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
   297
    __ reinit_heapbase();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
    // make sure we have no pending exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
      Label L;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   303
      __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
      __ jcc(Assembler::equal, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
      __ stop("StubRoutines::call_stub: entered with pending exception");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
      __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    // pass parameters if any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    BLOCK_COMMENT("pass parameters if any");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    Label parameters_done;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    __ movl(c_rarg3, parameter_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    __ testl(c_rarg3, c_rarg3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
    __ jcc(Assembler::zero, parameters_done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
    Label loop;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   318
    __ movptr(c_rarg2, parameters);       // parameter pointer
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   319
    __ movl(c_rarg1, c_rarg3);            // parameter counter is in c_rarg1
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
    __ BIND(loop);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   321
    __ movptr(rax, Address(c_rarg2, 0));// get parameter
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   322
    __ addptr(c_rarg2, wordSize);       // advance to next parameter
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   323
    __ decrementl(c_rarg1);             // decrement counter
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   324
    __ push(rax);                       // pass parameter
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    __ jcc(Assembler::notZero, loop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    // call Java function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    __ BIND(parameters_done);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   329
    __ movptr(rbx, method);             // get Method*
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   330
    __ movptr(c_rarg1, entry_point);    // get entry_point
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   331
    __ mov(r13, rsp);                   // set sender sp
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
    BLOCK_COMMENT("call Java function");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    __ call(c_rarg1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
    BLOCK_COMMENT("call_stub_return_address:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
    return_address = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    // store result depending on type (everything that is not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
    // T_OBJECT, T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   340
    __ movptr(c_rarg0, result);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    Label is_long, is_float, is_double, exit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
    __ movl(c_rarg1, result_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
    __ cmpl(c_rarg1, T_OBJECT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
    __ jcc(Assembler::equal, is_long);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
    __ cmpl(c_rarg1, T_LONG);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    __ jcc(Assembler::equal, is_long);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    __ cmpl(c_rarg1, T_FLOAT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    __ jcc(Assembler::equal, is_float);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    __ cmpl(c_rarg1, T_DOUBLE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
    __ jcc(Assembler::equal, is_double);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
    // handle T_INT case
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
    __ movl(Address(c_rarg0, 0), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
    __ BIND(exit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
    // pop parameters
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   358
    __ lea(rsp, rsp_after_call);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
    // verify that threads correspond
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
    {
32590
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   363
     Label L1, L2, L3;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   364
      __ cmpptr(r15_thread, thread);
32590
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   365
      __ jcc(Assembler::equal, L1);
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   366
      __ stop("StubRoutines::call_stub: r15_thread is corrupted");
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   367
      __ bind(L1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
      __ get_thread(rbx);
32590
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   369
      __ cmpptr(r15_thread, thread);
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   370
      __ jcc(Assembler::equal, L2);
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   371
      __ stop("StubRoutines::call_stub: r15_thread is modified by call");
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   372
      __ bind(L2);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   373
      __ cmpptr(r15_thread, rbx);
32590
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   374
      __ jcc(Assembler::equal, L3);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
      __ stop("StubRoutines::call_stub: threads must correspond");
32590
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   376
      __ bind(L3);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
    // restore regs belonging to calling function
8874
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   381
#ifdef _WIN64
31410
2a222ae1205f 8081247: AVX 512 extended support
mcberg
parents: 31404
diff changeset
   382
    // emit the restores for xmm regs
34162
16b54851eaf6 8140779: Code generation fixes for avx512
iveresov
parents: 33465
diff changeset
   383
    if (VM_Version::supports_evex()) {
32727
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32596
diff changeset
   384
      for (int i = xmm_save_first; i <= last_reg; i++) {
36561
b18243f4d955 8151002: Make Assembler methods vextract and vinsert match actual instructions
mikael
parents: 36555
diff changeset
   385
        __ vinsertf32x4(as_XMMRegister(i), as_XMMRegister(i), xmm_save(i), 0);
32727
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32596
diff changeset
   386
      }
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32596
diff changeset
   387
    } else {
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32596
diff changeset
   388
      for (int i = xmm_save_first; i <= last_reg; i++) {
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32596
diff changeset
   389
        __ movdqu(as_XMMRegister(i), xmm_save(i));
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32596
diff changeset
   390
      }
8874
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   391
    }
b2030880129c 6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents: 8498
diff changeset
   392
#endif
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   393
    __ movptr(r15, r15_save);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   394
    __ movptr(r14, r14_save);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   395
    __ movptr(r13, r13_save);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   396
    __ movptr(r12, r12_save);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   397
    __ movptr(rbx, rbx_save);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
#ifdef _WIN64
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   400
    __ movptr(rdi, rdi_save);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   401
    __ movptr(rsi, rsi_save);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
    __ ldmxcsr(mxcsr_save);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
    // restore rsp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   407
    __ addptr(rsp, -rsp_after_call_off * wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    // return
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
   410
    __ vzeroupper();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   411
    __ pop(rbp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    // handle return types different from T_INT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
    __ BIND(is_long);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    __ movq(Address(c_rarg0, 0), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    __ jmp(exit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
    __ BIND(is_float);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
    __ movflt(Address(c_rarg0, 0), xmm0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
    __ jmp(exit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
    __ BIND(is_double);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
    __ movdbl(Address(c_rarg0, 0), xmm0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
    __ jmp(exit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  // Return point for a Java call if there's an exception thrown in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  // Java code.  The exception is caught and transformed into a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  // pending exception stored in JavaThread that can be tested from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  // within the VM.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  // Note: Usually the parameters are removed by the callee. In case
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  // of an exception crossing an activation frame boundary, that is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  // not the case if the callee is compiled code => need to setup the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  // rsp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  // rax: exception oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  address generate_catch_exception() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
    StubCodeMark mark(this, "StubRoutines", "catch_exception");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    // same as in generate_call_stub():
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
    const Address rsp_after_call(rbp, rsp_after_call_off * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    const Address thread        (rbp, thread_off         * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
    // verify that threads correspond
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    {
32590
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   453
      Label L1, L2, L3;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   454
      __ cmpptr(r15_thread, thread);
32590
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   455
      __ jcc(Assembler::equal, L1);
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   456
      __ stop("StubRoutines::catch_exception: r15_thread is corrupted");
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   457
      __ bind(L1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
      __ get_thread(rbx);
32590
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   459
      __ cmpptr(r15_thread, thread);
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   460
      __ jcc(Assembler::equal, L2);
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   461
      __ stop("StubRoutines::catch_exception: r15_thread is modified by call");
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   462
      __ bind(L2);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   463
      __ cmpptr(r15_thread, rbx);
32590
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   464
      __ jcc(Assembler::equal, L3);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
      __ stop("StubRoutines::catch_exception: threads must correspond");
32590
66edb61f17d4 8133646: Internal Error: x86/vm/macroAssembler_x86.cpp:886 DEBUG MESSAGE: StubRoutines::call_stub: threads must correspond
dholmes
parents: 31584
diff changeset
   466
      __ bind(L3);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
    // set pending exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
    __ verify_oop(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   473
    __ movptr(Address(r15_thread, Thread::pending_exception_offset()), rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
    __ lea(rscratch1, ExternalAddress((address)__FILE__));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   475
    __ movptr(Address(r15_thread, Thread::exception_file_offset()), rscratch1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
    __ movl(Address(r15_thread, Thread::exception_line_offset()), (int)  __LINE__);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
    // complete return to VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
    assert(StubRoutines::_call_stub_return_address != NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
           "_call_stub_return_address must have been generated before");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
    __ jump(RuntimeAddress(StubRoutines::_call_stub_return_address));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  // Continuation point for runtime calls returning with a pending
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  // exception.  The pending exception check happened in the runtime
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  // or native call stub.  The pending exception in Thread is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  // converted into a Java-level exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  // Contract with Java-level exception handlers:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  // rax: exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  // rdx: throwing pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  // NOTE: At entry of this stub, exception-pc must be on stack !!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  address generate_forward_exception() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
    StubCodeMark mark(this, "StubRoutines", "forward exception");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
    // Upon entry, the sp points to the return address returning into
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
    // Java (interpreted or compiled) code; i.e., the return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
    // becomes the throwing pc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
    // Arguments pushed before the runtime call are still on the stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
    // but the exception handler will reset the stack pointer ->
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
    // ignore them.  A potential result in registers can be ignored as
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
    // well.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
    // make sure this code is only executed if there is a pending exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
      Label L;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   514
      __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t) NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
      __ jcc(Assembler::notEqual, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
      __ stop("StubRoutines::forward exception: no pending exception (1)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
      __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
    // compute exception handler into rbx
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   522
    __ movptr(c_rarg0, Address(rsp, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
    BLOCK_COMMENT("call exception_handler_for_return_address");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
    __ call_VM_leaf(CAST_FROM_FN_PTR(address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
                         SharedRuntime::exception_handler_for_return_address),
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4740
diff changeset
   526
                    r15_thread, c_rarg0);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   527
    __ mov(rbx, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
    // setup rax & rdx, remove return address & clear pending exception
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   530
    __ pop(rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   531
    __ movptr(rax, Address(r15_thread, Thread::pending_exception_offset()));
1888
bbf498fb4354 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 1437
diff changeset
   532
    __ movptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
    // make sure exception is set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
      Label L;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   538
      __ testptr(rax, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
      __ jcc(Assembler::notEqual, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
      __ stop("StubRoutines::forward exception: no pending exception (2)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
      __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
    // continue at exception handler (return address removed)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
    // rax: exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
    // rbx: exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
    // rdx: throwing pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
    __ verify_oop(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
    __ jmp(rbx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  // Support for jint atomic::xchg(jint exchange_value, volatile jint* dest)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  // Arguments :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
  //    c_rarg0: exchange_value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  //    c_rarg0: dest
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
  // Result:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
  //    *dest <- ex, return (orig *dest)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  address generate_atomic_xchg() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
    StubCodeMark mark(this, "StubRoutines", "atomic_xchg");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
    __ movl(rax, c_rarg0); // Copy to eax we need a return value anyhow
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
    __ xchgl(rax, Address(c_rarg1, 0)); // automatic LOCK
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
47634
6a0c42c40cd1 8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents: 47216
diff changeset
   574
  // Support for intptr_t atomic::xchg_long(jlong exchange_value, volatile jlong* dest)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  // Arguments :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  //    c_rarg0: exchange_value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
  //    c_rarg1: dest
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
  // Result:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
  //    *dest <- ex, return (orig *dest)
47634
6a0c42c40cd1 8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents: 47216
diff changeset
   582
  address generate_atomic_xchg_long() {
6a0c42c40cd1 8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents: 47216
diff changeset
   583
    StubCodeMark mark(this, "StubRoutines", "atomic_xchg_long");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   586
    __ movptr(rax, c_rarg0); // Copy to eax we need a return value anyhow
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   587
    __ xchgptr(rax, Address(c_rarg1, 0)); // automatic LOCK
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  // Support for jint atomic::atomic_cmpxchg(jint exchange_value, volatile jint* dest,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
  //                                         jint compare_value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
  // Arguments :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  //    c_rarg0: exchange_value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
  //    c_rarg1: dest
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
  //    c_rarg2: compare_value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
  // Result:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
  //    if ( compare_value == *dest ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  //       *dest = exchange_value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
  //       return compare_value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  //    else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  //       return *dest;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
  address generate_atomic_cmpxchg() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
    StubCodeMark mark(this, "StubRoutines", "atomic_cmpxchg");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
    __ movl(rax, c_rarg2);
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51976
diff changeset
   612
    __ lock();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
    __ cmpxchgl(c_rarg0, Address(c_rarg1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
48468
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
   619
  // Support for int8_t atomic::atomic_cmpxchg(int8_t exchange_value, volatile int8_t* dest,
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
   620
  //                                           int8_t compare_value)
27691
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   621
  //
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   622
  // Arguments :
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   623
  //    c_rarg0: exchange_value
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   624
  //    c_rarg1: dest
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   625
  //    c_rarg2: compare_value
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   626
  //
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   627
  // Result:
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   628
  //    if ( compare_value == *dest ) {
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   629
  //       *dest = exchange_value
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   630
  //       return compare_value;
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   631
  //    else
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   632
  //       return *dest;
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   633
  address generate_atomic_cmpxchg_byte() {
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   634
    StubCodeMark mark(this, "StubRoutines", "atomic_cmpxchg_byte");
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   635
    address start = __ pc();
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   636
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   637
    __ movsbq(rax, c_rarg2);
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51976
diff changeset
   638
    __ lock();
27691
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   639
    __ cmpxchgb(c_rarg0, Address(c_rarg1, 0));
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   640
    __ ret(0);
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   641
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   642
    return start;
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   643
  }
733f189ad1f7 8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents: 26434
diff changeset
   644
48468
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
   645
  // Support for int64_t atomic::atomic_cmpxchg(int64_t exchange_value,
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
   646
  //                                            volatile int64_t* dest,
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
   647
  //                                            int64_t compare_value)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
  // Arguments :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
  //    c_rarg0: exchange_value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  //    c_rarg1: dest
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
  //    c_rarg2: compare_value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
  // Result:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
  //    if ( compare_value == *dest ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
  //       *dest = exchange_value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
  //       return compare_value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
  //    else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
  //       return *dest;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
  address generate_atomic_cmpxchg_long() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
    StubCodeMark mark(this, "StubRoutines", "atomic_cmpxchg_long");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
    __ movq(rax, c_rarg2);
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51976
diff changeset
   664
    __ lock();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
    __ cmpxchgq(c_rarg0, Address(c_rarg1, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
  // Support for jint atomic::add(jint add_value, volatile jint* dest)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  // Arguments :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
  //    c_rarg0: add_value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
  //    c_rarg1: dest
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
  // Result:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
  //    *dest += add_value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
  //    return *dest;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
  address generate_atomic_add() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
    StubCodeMark mark(this, "StubRoutines", "atomic_add");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
    __ movl(rax, c_rarg0);
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51976
diff changeset
   685
    __ lock();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
    __ xaddl(Address(c_rarg1, 0), c_rarg0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
    __ addl(rax, c_rarg0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
  // Support for intptr_t atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  // Arguments :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
  //    c_rarg0: add_value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
  //    c_rarg1: dest
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
  // Result:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
  //    *dest += add_value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
  //    return *dest;
48468
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
   702
  address generate_atomic_add_long() {
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
   703
    StubCodeMark mark(this, "StubRoutines", "atomic_add_long");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   706
    __ movptr(rax, c_rarg0); // Copy to eax we need a return value anyhow
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51976
diff changeset
   707
    __ lock();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   708
    __ xaddptr(Address(c_rarg1, 0), c_rarg0);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   709
    __ addptr(rax, c_rarg0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
  // Support for intptr_t OrderAccess::fence()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  // Arguments :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
  // Result:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
  address generate_orderaccess_fence() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
    StubCodeMark mark(this, "StubRoutines", "orderaccess_fence");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
    address start = __ pc();
2338
a8660a1b709b 6822204: volatile fences should prefer lock:addl to actual mfence instructions
never
parents: 2259
diff changeset
   723
    __ membar(Assembler::StoreLoad);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
  // Support for intptr_t get_previous_fp()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
  // This routine is used to find the previous frame pointer for the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
  // caller (current_frame_guess). This is used as part of debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
  // ps() is seemingly lost trying to find frames.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
  // This code assumes that caller current_frame_guess) has a frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
  address generate_get_previous_fp() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
    StubCodeMark mark(this, "StubRoutines", "get_previous_fp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
    const Address old_fp(rbp, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
    const Address older_fp(rax, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
    __ enter();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   742
    __ movptr(rax, old_fp); // callers fp
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   743
    __ movptr(rax, older_fp); // the frame for ps()
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   744
    __ pop(rbp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
11961
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   750
  // Support for intptr_t get_previous_sp()
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   751
  //
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   752
  // This routine is used to find the previous stack pointer for the
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   753
  // caller.
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   754
  address generate_get_previous_sp() {
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   755
    StubCodeMark mark(this, "StubRoutines", "get_previous_sp");
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   756
    address start = __ pc();
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   757
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   758
    __ movptr(rax, rsp);
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   759
    __ addptr(rax, 8); // return address is at the top of the stack.
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   760
    __ ret(0);
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   761
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   762
    return start;
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   763
  }
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
   764
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
  //----------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
  // Support for void verify_mxcsr()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
  // This routine is used with -Xcheck:jni to verify that native
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
  // JNI code does not return to Java code without restoring the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
  // MXCSR register to our expected state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
  address generate_verify_mxcsr() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
    StubCodeMark mark(this, "StubRoutines", "verify_mxcsr");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
    const Address mxcsr_save(rsp, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
    if (CheckJNICalls) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
      Label ok_ret;
18958
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
   780
      ExternalAddress mxcsr_std(StubRoutines::addr_mxcsr_std());
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   781
      __ push(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   782
      __ subptr(rsp, wordSize);      // allocate a temp location
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
      __ stmxcsr(mxcsr_save);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
      __ movl(rax, mxcsr_save);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
      __ andl(rax, MXCSR_MASK);    // Only check control and mask bits
18958
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
   786
      __ cmp32(rax, mxcsr_std);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
      __ jcc(Assembler::equal, ok_ret);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
      __ warn("MXCSR changed by native JNI code, use -XX:+RestoreMXCSROnJNICall");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
18958
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
   791
      __ ldmxcsr(mxcsr_std);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
      __ bind(ok_ret);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   794
      __ addptr(rsp, wordSize);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   795
      __ pop(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
  address generate_f2i_fixup() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
    StubCodeMark mark(this, "StubRoutines", "f2i_fixup");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
    Address inout(rsp, 5 * wordSize); // return address + 4 saves
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
    Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   811
    __ push(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   812
    __ push(c_rarg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   813
    __ push(c_rarg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   814
    __ push(c_rarg1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
    __ movl(rax, 0x7f800000);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
    __ xorl(c_rarg3, c_rarg3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
    __ movl(c_rarg2, inout);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
    __ movl(c_rarg1, c_rarg2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
    __ andl(c_rarg1, 0x7fffffff);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
    __ cmpl(rax, c_rarg1); // NaN? -> 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
    __ jcc(Assembler::negative, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
    __ testl(c_rarg2, c_rarg2); // signed ? min_jint : max_jint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
    __ movl(c_rarg3, 0x80000000);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
    __ movl(rax, 0x7fffffff);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
    __ cmovl(Assembler::positive, c_rarg3, rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
    __ bind(L);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   829
    __ movptr(inout, c_rarg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   830
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   831
    __ pop(c_rarg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   832
    __ pop(c_rarg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   833
    __ pop(c_rarg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   834
    __ pop(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
  address generate_f2l_fixup() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
    StubCodeMark mark(this, "StubRoutines", "f2l_fixup");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
    Address inout(rsp, 5 * wordSize); // return address + 4 saves
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
    Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   848
    __ push(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   849
    __ push(c_rarg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   850
    __ push(c_rarg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   851
    __ push(c_rarg1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
    __ movl(rax, 0x7f800000);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
    __ xorl(c_rarg3, c_rarg3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
    __ movl(c_rarg2, inout);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
    __ movl(c_rarg1, c_rarg2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
    __ andl(c_rarg1, 0x7fffffff);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
    __ cmpl(rax, c_rarg1); // NaN? -> 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
    __ jcc(Assembler::negative, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
    __ testl(c_rarg2, c_rarg2); // signed ? min_jlong : max_jlong
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
    __ mov64(c_rarg3, 0x8000000000000000);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
    __ mov64(rax, 0x7fffffffffffffff);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   863
    __ cmov(Assembler::positive, c_rarg3, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
    __ bind(L);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   866
    __ movptr(inout, c_rarg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   867
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   868
    __ pop(c_rarg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   869
    __ pop(c_rarg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   870
    __ pop(c_rarg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   871
    __ pop(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
  address generate_d2i_fixup() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
    StubCodeMark mark(this, "StubRoutines", "d2i_fixup");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
    Address inout(rsp, 6 * wordSize); // return address + 5 saves
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
    Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   886
    __ push(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   887
    __ push(c_rarg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   888
    __ push(c_rarg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   889
    __ push(c_rarg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   890
    __ push(c_rarg0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
    __ movl(rax, 0x7ff00000);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
    __ movq(c_rarg2, inout);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
    __ movl(c_rarg3, c_rarg2);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   895
    __ mov(c_rarg1, c_rarg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   896
    __ mov(c_rarg0, c_rarg2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
    __ negl(c_rarg3);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   898
    __ shrptr(c_rarg1, 0x20);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
    __ orl(c_rarg3, c_rarg2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
    __ andl(c_rarg1, 0x7fffffff);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
    __ xorl(c_rarg2, c_rarg2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
    __ shrl(c_rarg3, 0x1f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
    __ orl(c_rarg1, c_rarg3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
    __ cmpl(rax, c_rarg1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
    __ jcc(Assembler::negative, L); // NaN -> 0
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   906
    __ testptr(c_rarg0, c_rarg0); // signed ? min_jint : max_jint
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
    __ movl(c_rarg2, 0x80000000);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
    __ movl(rax, 0x7fffffff);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   909
    __ cmov(Assembler::positive, c_rarg2, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
    __ bind(L);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   912
    __ movptr(inout, c_rarg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   913
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   914
    __ pop(c_rarg0);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   915
    __ pop(c_rarg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   916
    __ pop(c_rarg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   917
    __ pop(c_rarg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   918
    __ pop(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
  address generate_d2l_fixup() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
    StubCodeMark mark(this, "StubRoutines", "d2l_fixup");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
    Address inout(rsp, 6 * wordSize); // return address + 5 saves
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
    Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   933
    __ push(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   934
    __ push(c_rarg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   935
    __ push(c_rarg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   936
    __ push(c_rarg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   937
    __ push(c_rarg0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
    __ movl(rax, 0x7ff00000);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
    __ movq(c_rarg2, inout);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
    __ movl(c_rarg3, c_rarg2);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   942
    __ mov(c_rarg1, c_rarg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   943
    __ mov(c_rarg0, c_rarg2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
    __ negl(c_rarg3);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   945
    __ shrptr(c_rarg1, 0x20);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
    __ orl(c_rarg3, c_rarg2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
    __ andl(c_rarg1, 0x7fffffff);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
    __ xorl(c_rarg2, c_rarg2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
    __ shrl(c_rarg3, 0x1f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
    __ orl(c_rarg1, c_rarg3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
    __ cmpl(rax, c_rarg1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
    __ jcc(Assembler::negative, L); // NaN -> 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
    __ testq(c_rarg0, c_rarg0); // signed ? min_jlong : max_jlong
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
    __ mov64(c_rarg2, 0x8000000000000000);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
    __ mov64(rax, 0x7fffffffffffffff);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
    __ cmovq(Assembler::positive, c_rarg2, rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
    __ movq(inout, c_rarg2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   961
    __ pop(c_rarg0);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   962
    __ pop(c_rarg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   963
    __ pop(c_rarg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   964
    __ pop(c_rarg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
   965
    __ pop(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
  address generate_fp_mask(const char *stub_name, int64_t mask) {
5249
5cac34e6fe54 6940701: Don't align loops in stubs for Niagara sparc
kvn
parents: 5050
diff changeset
   973
    __ align(CodeEntryAlignment);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
    StubCodeMark mark(this, "StubRoutines", stub_name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
    __ emit_data64( mask, relocInfo::none );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
    __ emit_data64( mask, relocInfo::none );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
54750
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   983
  address generate_vector_mask(const char *stub_name, int64_t mask) {
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   984
    __ align(CodeEntryAlignment);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   985
    StubCodeMark mark(this, "StubRoutines", stub_name);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   986
    address start = __ pc();
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   987
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   988
    __ emit_data64(mask, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   989
    __ emit_data64(mask, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   990
    __ emit_data64(mask, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   991
    __ emit_data64(mask, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   992
    __ emit_data64(mask, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   993
    __ emit_data64(mask, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   994
    __ emit_data64(mask, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   995
    __ emit_data64(mask, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   996
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   997
    return start;
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   998
  }
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
   999
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1000
  address generate_vector_byte_perm_mask(const char *stub_name) {
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1001
    __ align(CodeEntryAlignment);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1002
    StubCodeMark mark(this, "StubRoutines", stub_name);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1003
    address start = __ pc();
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1004
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1005
    __ emit_data64(0x0000000000000001, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1006
    __ emit_data64(0x0000000000000003, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1007
    __ emit_data64(0x0000000000000005, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1008
    __ emit_data64(0x0000000000000007, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1009
    __ emit_data64(0x0000000000000000, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1010
    __ emit_data64(0x0000000000000002, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1011
    __ emit_data64(0x0000000000000004, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1012
    __ emit_data64(0x0000000000000006, relocInfo::none);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1013
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1014
    return start;
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1015
  }
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  1016
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
  // Non-destructive plausibility checks for oops
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
  // Arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
  //    all args on stack!
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
  // Stack after saving c_rarg3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
  //    [tos + 0]: saved c_rarg3
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
  //    [tos + 1]: saved c_rarg2
371
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1025
  //    [tos + 2]: saved r12 (several TemplateTable methods use it)
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1026
  //    [tos + 3]: saved flags
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1027
  //    [tos + 4]: return address
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1028
  //  * [tos + 5]: error message (char*)
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1029
  //  * [tos + 6]: object to verify (oop)
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1030
  //  * [tos + 7]: saved rax - saved by caller and bashed
5706
0c91076143f9 6958254: -XX:+VerifyOops is broken on x86
kvn
parents: 5547
diff changeset
  1031
  //  * [tos + 8]: saved r10 (rscratch1) - saved by caller
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
  //  * = popped on exit
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
  address generate_verify_oop() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
    StubCodeMark mark(this, "StubRoutines", "verify_oop");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
    Label exit, error;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1039
    __ pushf();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
    __ incrementl(ExternalAddress((address) StubRoutines::verify_oop_count_addr()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1042
    __ push(r12);
371
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1043
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
    // save c_rarg2 and c_rarg3
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1045
    __ push(c_rarg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1046
    __ push(c_rarg3);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
371
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1048
    enum {
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1049
           // After previous pushes.
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1050
           oop_to_verify = 6 * wordSize,
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1051
           saved_rax     = 7 * wordSize,
5706
0c91076143f9 6958254: -XX:+VerifyOops is broken on x86
kvn
parents: 5547
diff changeset
  1052
           saved_r10     = 8 * wordSize,
371
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1053
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1054
           // Before the call to MacroAssembler::debug(), see below.
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1055
           return_addr   = 16 * wordSize,
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1056
           error_msg     = 17 * wordSize
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1057
    };
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1058
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
    // get object
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1060
    __ movptr(rax, Address(rsp, oop_to_verify));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
    // make sure object is 'reasonable'
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1063
    __ testptr(rax, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
    __ jcc(Assembler::zero, exit); // if obj is NULL it is OK
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50179
diff changeset
  1065
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50179
diff changeset
  1066
#if INCLUDE_ZGC
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50179
diff changeset
  1067
    if (UseZGC) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50179
diff changeset
  1068
      // Check if metadata bits indicate a bad oop
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50179
diff changeset
  1069
      __ testptr(rax, Address(r15_thread, ZThreadLocalData::address_bad_mask_offset()));
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50179
diff changeset
  1070
      __ jcc(Assembler::notZero, error);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50179
diff changeset
  1071
    }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50179
diff changeset
  1072
#endif
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50179
diff changeset
  1073
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
    // Check if the oop is in the right area of memory
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1075
    __ movptr(c_rarg2, rax);
1888
bbf498fb4354 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 1437
diff changeset
  1076
    __ movptr(c_rarg3, (intptr_t) Universe::verify_oop_mask());
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1077
    __ andptr(c_rarg2, c_rarg3);
1888
bbf498fb4354 6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents: 1437
diff changeset
  1078
    __ movptr(c_rarg3, (intptr_t) Universe::verify_oop_bits());
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1079
    __ cmpptr(c_rarg2, c_rarg3);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
    __ jcc(Assembler::notZero, error);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
371
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1082
    // set r12 to heapbase for load_klass()
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1083
    __ reinit_heapbase();
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1084
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1085
    // make sure klass is 'reasonable', which is not zero.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  1086
    __ load_klass(rax, rax);  // get klass
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1087
    __ testptr(rax, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
    __ jcc(Assembler::zero, error); // if klass is NULL it is broken
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
    // return if everything seems ok
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
    __ bind(exit);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1092
    __ movptr(rax, Address(rsp, saved_rax));     // get saved rax back
5706
0c91076143f9 6958254: -XX:+VerifyOops is broken on x86
kvn
parents: 5547
diff changeset
  1093
    __ movptr(rscratch1, Address(rsp, saved_r10)); // get saved r10 back
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1094
    __ pop(c_rarg3);                             // restore c_rarg3
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1095
    __ pop(c_rarg2);                             // restore c_rarg2
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1096
    __ pop(r12);                                 // restore r12
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1097
    __ popf();                                   // restore flags
5706
0c91076143f9 6958254: -XX:+VerifyOops is broken on x86
kvn
parents: 5547
diff changeset
  1098
    __ ret(4 * wordSize);                        // pop caller saved stuff
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
    // handle errors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
    __ bind(error);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1102
    __ movptr(rax, Address(rsp, saved_rax));     // get saved rax back
5706
0c91076143f9 6958254: -XX:+VerifyOops is broken on x86
kvn
parents: 5547
diff changeset
  1103
    __ movptr(rscratch1, Address(rsp, saved_r10)); // get saved r10 back
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1104
    __ pop(c_rarg3);                             // get saved c_rarg3 back
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1105
    __ pop(c_rarg2);                             // get saved c_rarg2 back
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1106
    __ pop(r12);                                 // get saved r12 back
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1107
    __ popf();                                   // get saved flags off stack --
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
                                                 // will be ignored
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1110
    __ pusha();                                  // push registers
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
                                                 // (rip is already
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
                                                 // already pushed)
371
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1113
    // debug(char* msg, int64_t pc, int64_t regs[])
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
    // We've popped the registers we'd saved (c_rarg3, c_rarg2 and flags), and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
    // pushed all the registers, so now the stack looks like:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
    //     [tos +  0] 16 saved registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
    //     [tos + 16] return address
371
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1118
    //   * [tos + 17] error message (char*)
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1119
    //   * [tos + 18] object to verify (oop)
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1120
    //   * [tos + 19] saved rax - saved by caller and bashed
5706
0c91076143f9 6958254: -XX:+VerifyOops is broken on x86
kvn
parents: 5547
diff changeset
  1121
    //   * [tos + 20] saved r10 (rscratch1) - saved by caller
371
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1122
    //   * = popped on exit
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1123
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1124
    __ movptr(c_rarg0, Address(rsp, error_msg));    // pass address of error message
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1125
    __ movptr(c_rarg1, Address(rsp, return_addr));  // pass return address
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1126
    __ movq(c_rarg2, rsp);                          // pass address of regs on stack
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1127
    __ mov(r12, rsp);                               // remember rsp
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1128
    __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1129
    __ andptr(rsp, -16);                            // align stack as required by ABI
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
    BLOCK_COMMENT("call MacroAssembler::debug");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1131
    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug64)));
58103
689a80d20550 8230762: Change MacroAssembler::debug32/64 to use fatal instead of assert
chagedorn
parents: 57804
diff changeset
  1132
    __ hlt();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
  // Verify that a register contains clean 32-bits positive value
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
  // (high 32-bits are 0) so it could be used in 64-bits shifts.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
  //  Input:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
  //    Rint  -  32-bits value
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
  //    Rtmp  -  scratch
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
  void assert_clean_int(Register Rint, Register Rtmp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
    Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
    assert_different_registers(Rtmp, Rint);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
    __ movslq(Rtmp, Rint);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
    __ cmpq(Rtmp, Rint);
371
1aacedc9db7c 6689060: Escape Analysis does not work with Compressed Oops
kvn
parents: 360
diff changeset
  1150
    __ jcc(Assembler::equal, L);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
    __ stop("high 32-bits of int value are not 0");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
  //  Generate overlap test for array copy stubs
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
  //  Input:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
  //     c_rarg0 - from
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
  //     c_rarg1 - to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
  //     c_rarg2 - element count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
  //  Output:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
  //     rax   - &from[element count - 1]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
  void array_overlap_test(address no_overlap_target, Address::ScaleFactor sf) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
    assert(no_overlap_target != NULL, "must be generated");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
    array_overlap_test(no_overlap_target, NULL, sf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
  void array_overlap_test(Label& L_no_overlap, Address::ScaleFactor sf) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
    array_overlap_test(NULL, &L_no_overlap, sf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
  void array_overlap_test(address no_overlap_target, Label* NOLp, Address::ScaleFactor sf) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
    const Register from     = c_rarg0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
    const Register to       = c_rarg1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
    const Register count    = c_rarg2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
    const Register end_from = rax;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1179
    __ cmpptr(to, from);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1180
    __ lea(end_from, Address(from, count, sf, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
    if (NOLp == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
      ExternalAddress no_overlap(no_overlap_target);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
      __ jump_cc(Assembler::belowEqual, no_overlap);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1184
      __ cmpptr(to, end_from);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
      __ jump_cc(Assembler::aboveEqual, no_overlap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
      __ jcc(Assembler::belowEqual, (*NOLp));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1188
      __ cmpptr(to, end_from);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
      __ jcc(Assembler::aboveEqual, (*NOLp));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1193
  // Shuffle first three arg regs on Windows into Linux/Solaris locations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1194
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
  // Outputs:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
  //    rdi - rcx
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
  //    rsi - rdx
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
  //    rdx - r8
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
  //    rcx - r9
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
  // Registers r9 and r10 are used to save rdi and rsi on Windows, which latter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
  // are non-volatile.  r9 and r10 should not be used by the caller.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
  //
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1204
  DEBUG_ONLY(bool regs_in_thread;)
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1205
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
  void setup_arg_regs(int nargs = 3) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
    const Register saved_rdi = r9;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
    const Register saved_rsi = r10;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
    assert(nargs == 3 || nargs == 4, "else fix");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
#ifdef _WIN64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
    assert(c_rarg0 == rcx && c_rarg1 == rdx && c_rarg2 == r8 && c_rarg3 == r9,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
           "unexpected argument registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1213
    if (nargs >= 4)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1214
      __ mov(rax, r9);  // r9 is also saved_rdi
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1215
    __ movptr(saved_rdi, rdi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1216
    __ movptr(saved_rsi, rsi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1217
    __ mov(rdi, rcx); // c_rarg0
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1218
    __ mov(rsi, rdx); // c_rarg1
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1219
    __ mov(rdx, r8);  // c_rarg2
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
    if (nargs >= 4)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1221
      __ mov(rcx, rax); // c_rarg3 (via rax)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
    assert(c_rarg0 == rdi && c_rarg1 == rsi && c_rarg2 == rdx && c_rarg3 == rcx,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1224
           "unexpected argument registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1225
#endif
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1226
    DEBUG_ONLY(regs_in_thread = false;)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
  void restore_arg_regs() {
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1230
    assert(!regs_in_thread, "wrong call to restore_arg_regs");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
    const Register saved_rdi = r9;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
    const Register saved_rsi = r10;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
#ifdef _WIN64
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1234
    __ movptr(rdi, saved_rdi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1235
    __ movptr(rsi, saved_rsi);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1238
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1239
  // This is used in places where r10 is a scratch register, and can
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1240
  // be adapted if r9 is needed also.
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1241
  void setup_arg_regs_using_thread() {
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1242
    const Register saved_r15 = r9;
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1243
#ifdef _WIN64
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1244
    __ mov(saved_r15, r15);  // r15 is callee saved and needs to be restored
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1245
    __ get_thread(r15_thread);
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1246
    assert(c_rarg0 == rcx && c_rarg1 == rdx && c_rarg2 == r8 && c_rarg3 == r9,
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1247
           "unexpected argument registers");
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1248
    __ movptr(Address(r15_thread, in_bytes(JavaThread::windows_saved_rdi_offset())), rdi);
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1249
    __ movptr(Address(r15_thread, in_bytes(JavaThread::windows_saved_rsi_offset())), rsi);
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1250
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1251
    __ mov(rdi, rcx); // c_rarg0
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1252
    __ mov(rsi, rdx); // c_rarg1
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1253
    __ mov(rdx, r8);  // c_rarg2
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1254
#else
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1255
    assert(c_rarg0 == rdi && c_rarg1 == rsi && c_rarg2 == rdx && c_rarg3 == rcx,
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1256
           "unexpected argument registers");
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1257
#endif
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1258
    DEBUG_ONLY(regs_in_thread = true;)
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1259
  }
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1260
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1261
  void restore_arg_regs_using_thread() {
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1262
    assert(regs_in_thread, "wrong call to restore_arg_regs");
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1263
    const Register saved_r15 = r9;
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1264
#ifdef _WIN64
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1265
    __ get_thread(r15_thread);
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1266
    __ movptr(rsi, Address(r15_thread, in_bytes(JavaThread::windows_saved_rsi_offset())));
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1267
    __ movptr(rdi, Address(r15_thread, in_bytes(JavaThread::windows_saved_rdi_offset())));
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1268
    __ mov(r15, saved_r15);  // r15 is callee saved and needs to be restored
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1269
#endif
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1270
  }
1437
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1271
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
  // Copy big chunks forward
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
  // Inputs:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
  //   end_from     - source arrays end address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
  //   end_to       - destination array end address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1277
  //   qword_count  - 64-bits element count, negative
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
  //   to           - scratch
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1279
  //   L_copy_bytes - entry label
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
  //   L_copy_8_bytes  - exit  label
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
  //
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1282
  void copy_bytes_forward(Register end_from, Register end_to,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
                             Register qword_count, Register to,
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1284
                             Label& L_copy_bytes, Label& L_copy_8_bytes) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
    DEBUG_ONLY(__ stop("enter at entry label, not here"));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1286
    Label L_loop;
5249
5cac34e6fe54 6940701: Don't align loops in stubs for Niagara sparc
kvn
parents: 5050
diff changeset
  1287
    __ align(OptoLoopAlignment);
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1288
    if (UseUnalignedLoadStores) {
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1289
      Label L_end;
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1290
      // Copy 64-bytes per iteration
30624
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30299
diff changeset
  1291
      if (UseAVX > 2) {
58462
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1292
        Label L_loop_avx512, L_loop_avx2, L_32_byte_head, L_above_threshold, L_below_threshold;
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1293
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1294
        __ BIND(L_copy_bytes);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1295
        __ cmpptr(qword_count, (-1 * AVX3Threshold / 8));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1296
        __ jccb(Assembler::less, L_above_threshold);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1297
        __ jmpb(L_below_threshold);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1298
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1299
        __ bind(L_loop_avx512);
32727
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32596
diff changeset
  1300
        __ evmovdqul(xmm0, Address(end_from, qword_count, Address::times_8, -56), Assembler::AVX_512bit);
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32596
diff changeset
  1301
        __ evmovdqul(Address(end_to, qword_count, Address::times_8, -56), xmm0, Assembler::AVX_512bit);
58462
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1302
        __ bind(L_above_threshold);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1303
        __ addptr(qword_count, 8);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1304
        __ jcc(Assembler::lessEqual, L_loop_avx512);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1305
        __ jmpb(L_32_byte_head);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1306
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1307
        __ bind(L_loop_avx2);
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1308
        __ vmovdqu(xmm0, Address(end_from, qword_count, Address::times_8, -56));
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1309
        __ vmovdqu(Address(end_to, qword_count, Address::times_8, -56), xmm0);
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1310
        __ vmovdqu(xmm1, Address(end_from, qword_count, Address::times_8, -24));
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1311
        __ vmovdqu(Address(end_to, qword_count, Address::times_8, -24), xmm1);
58462
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1312
        __ bind(L_below_threshold);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1313
        __ addptr(qword_count, 8);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1314
        __ jcc(Assembler::lessEqual, L_loop_avx2);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1315
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1316
        __ bind(L_32_byte_head);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1317
        __ subptr(qword_count, 4);  // sub(8) and add(4)
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1318
        __ jccb(Assembler::greater, L_end);
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1319
      } else {
58462
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1320
        __ BIND(L_loop);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1321
        if (UseAVX == 2) {
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1322
          __ vmovdqu(xmm0, Address(end_from, qword_count, Address::times_8, -56));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1323
          __ vmovdqu(Address(end_to, qword_count, Address::times_8, -56), xmm0);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1324
          __ vmovdqu(xmm1, Address(end_from, qword_count, Address::times_8, -24));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1325
          __ vmovdqu(Address(end_to, qword_count, Address::times_8, -24), xmm1);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1326
        } else {
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1327
          __ movdqu(xmm0, Address(end_from, qword_count, Address::times_8, -56));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1328
          __ movdqu(Address(end_to, qword_count, Address::times_8, -56), xmm0);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1329
          __ movdqu(xmm1, Address(end_from, qword_count, Address::times_8, -40));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1330
          __ movdqu(Address(end_to, qword_count, Address::times_8, -40), xmm1);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1331
          __ movdqu(xmm2, Address(end_from, qword_count, Address::times_8, -24));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1332
          __ movdqu(Address(end_to, qword_count, Address::times_8, -24), xmm2);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1333
          __ movdqu(xmm3, Address(end_from, qword_count, Address::times_8, - 8));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1334
          __ movdqu(Address(end_to, qword_count, Address::times_8, - 8), xmm3);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1335
        }
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1336
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1337
        __ BIND(L_copy_bytes);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1338
        __ addptr(qword_count, 8);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1339
        __ jcc(Assembler::lessEqual, L_loop);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1340
        __ subptr(qword_count, 4);  // sub(8) and add(4)
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1341
        __ jccb(Assembler::greater, L_end);
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1342
      }
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1343
      // Copy trailing 32 bytes
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1344
      if (UseAVX >= 2) {
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1345
        __ vmovdqu(xmm0, Address(end_from, qword_count, Address::times_8, -24));
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1346
        __ vmovdqu(Address(end_to, qword_count, Address::times_8, -24), xmm0);
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1347
      } else {
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1348
        __ movdqu(xmm0, Address(end_from, qword_count, Address::times_8, -24));
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1349
        __ movdqu(Address(end_to, qword_count, Address::times_8, -24), xmm0);
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1350
        __ movdqu(xmm1, Address(end_from, qword_count, Address::times_8, - 8));
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1351
        __ movdqu(Address(end_to, qword_count, Address::times_8, - 8), xmm1);
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1352
      }
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1353
      __ addptr(qword_count, 4);
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1354
      __ BIND(L_end);
16624
9dbd4b210bf9 8011102: Clear AVX registers after return from JNI call
kvn
parents: 15115
diff changeset
  1355
      if (UseAVX >= 2) {
9dbd4b210bf9 8011102: Clear AVX registers after return from JNI call
kvn
parents: 15115
diff changeset
  1356
        // clean upper bits of YMM registers
30299
1f6f7d1e0c1e 8078113: 8011102 changes may cause incorrect results
kvn
parents: 29695
diff changeset
  1357
        __ vpxor(xmm0, xmm0);
1f6f7d1e0c1e 8078113: 8011102 changes may cause incorrect results
kvn
parents: 29695
diff changeset
  1358
        __ vpxor(xmm1, xmm1);
16624
9dbd4b210bf9 8011102: Clear AVX registers after return from JNI call
kvn
parents: 15115
diff changeset
  1359
      }
1437
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1360
    } else {
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1361
      // Copy 32-bytes per iteration
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1362
      __ BIND(L_loop);
1437
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1363
      __ movq(to, Address(end_from, qword_count, Address::times_8, -24));
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1364
      __ movq(Address(end_to, qword_count, Address::times_8, -24), to);
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1365
      __ movq(to, Address(end_from, qword_count, Address::times_8, -16));
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1366
      __ movq(Address(end_to, qword_count, Address::times_8, -16), to);
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1367
      __ movq(to, Address(end_from, qword_count, Address::times_8, - 8));
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1368
      __ movq(Address(end_to, qword_count, Address::times_8, - 8), to);
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1369
      __ movq(to, Address(end_from, qword_count, Address::times_8, - 0));
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1370
      __ movq(Address(end_to, qword_count, Address::times_8, - 0), to);
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1371
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1372
      __ BIND(L_copy_bytes);
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1373
      __ addptr(qword_count, 4);
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1374
      __ jcc(Assembler::lessEqual, L_loop);
1437
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1375
    }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1376
    __ subptr(qword_count, 4);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
    __ jcc(Assembler::less, L_copy_8_bytes); // Copy trailing qwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
  // Copy big chunks backward
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
  // Inputs:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
  //   from         - source arrays address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
  //   dest         - destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
  //   qword_count  - 64-bits element count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
  //   to           - scratch
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1387
  //   L_copy_bytes - entry label
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
  //   L_copy_8_bytes  - exit  label
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
  //
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1390
  void copy_bytes_backward(Register from, Register dest,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
                              Register qword_count, Register to,
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1392
                              Label& L_copy_bytes, Label& L_copy_8_bytes) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
    DEBUG_ONLY(__ stop("enter at entry label, not here"));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
    Label L_loop;
5249
5cac34e6fe54 6940701: Don't align loops in stubs for Niagara sparc
kvn
parents: 5050
diff changeset
  1395
    __ align(OptoLoopAlignment);
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1396
    if (UseUnalignedLoadStores) {
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1397
      Label L_end;
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1398
      // Copy 64-bytes per iteration
30624
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30299
diff changeset
  1399
      if (UseAVX > 2) {
58462
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1400
        Label L_loop_avx512, L_loop_avx2, L_32_byte_head, L_above_threshold, L_below_threshold;
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1401
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1402
        __ BIND(L_copy_bytes);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1403
        __ cmpptr(qword_count, (AVX3Threshold / 8));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1404
        __ jccb(Assembler::greater, L_above_threshold);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1405
        __ jmpb(L_below_threshold);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1406
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1407
        __ BIND(L_loop_avx512);
34203
6817dadf6c7e 8142980: SKX SpecJvm2008 - Derby
mcberg
parents: 34162
diff changeset
  1408
        __ evmovdqul(xmm0, Address(from, qword_count, Address::times_8, 0), Assembler::AVX_512bit);
6817dadf6c7e 8142980: SKX SpecJvm2008 - Derby
mcberg
parents: 34162
diff changeset
  1409
        __ evmovdqul(Address(dest, qword_count, Address::times_8, 0), xmm0, Assembler::AVX_512bit);
58462
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1410
        __ bind(L_above_threshold);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1411
        __ subptr(qword_count, 8);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1412
        __ jcc(Assembler::greaterEqual, L_loop_avx512);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1413
        __ jmpb(L_32_byte_head);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1414
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1415
        __ bind(L_loop_avx2);
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1416
        __ vmovdqu(xmm0, Address(from, qword_count, Address::times_8, 32));
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1417
        __ vmovdqu(Address(dest, qword_count, Address::times_8, 32), xmm0);
58462
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1418
        __ vmovdqu(xmm1, Address(from, qword_count, Address::times_8, 0));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1419
        __ vmovdqu(Address(dest, qword_count, Address::times_8, 0), xmm1);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1420
        __ bind(L_below_threshold);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1421
        __ subptr(qword_count, 8);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1422
        __ jcc(Assembler::greaterEqual, L_loop_avx2);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1423
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1424
        __ bind(L_32_byte_head);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1425
        __ addptr(qword_count, 4);  // add(8) and sub(4)
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1426
        __ jccb(Assembler::less, L_end);
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1427
      } else {
58462
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1428
        __ BIND(L_loop);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1429
        if (UseAVX == 2) {
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1430
          __ vmovdqu(xmm0, Address(from, qword_count, Address::times_8, 32));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1431
          __ vmovdqu(Address(dest, qword_count, Address::times_8, 32), xmm0);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1432
          __ vmovdqu(xmm1, Address(from, qword_count, Address::times_8,  0));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1433
          __ vmovdqu(Address(dest, qword_count, Address::times_8,  0), xmm1);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1434
        } else {
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1435
          __ movdqu(xmm0, Address(from, qword_count, Address::times_8, 48));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1436
          __ movdqu(Address(dest, qword_count, Address::times_8, 48), xmm0);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1437
          __ movdqu(xmm1, Address(from, qword_count, Address::times_8, 32));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1438
          __ movdqu(Address(dest, qword_count, Address::times_8, 32), xmm1);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1439
          __ movdqu(xmm2, Address(from, qword_count, Address::times_8, 16));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1440
          __ movdqu(Address(dest, qword_count, Address::times_8, 16), xmm2);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1441
          __ movdqu(xmm3, Address(from, qword_count, Address::times_8,  0));
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1442
          __ movdqu(Address(dest, qword_count, Address::times_8,  0), xmm3);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1443
        }
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1444
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1445
        __ BIND(L_copy_bytes);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1446
        __ subptr(qword_count, 8);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1447
        __ jcc(Assembler::greaterEqual, L_loop);
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1448
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1449
        __ addptr(qword_count, 4);  // add(8) and sub(4)
c6f1226cfb72 8221092: UseAVX=3 has performance degredation on Skylake (X7) processors
vdeshpande
parents: 58103
diff changeset
  1450
        __ jccb(Assembler::less, L_end);
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1451
      }
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1452
      // Copy trailing 32 bytes
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1453
      if (UseAVX >= 2) {
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1454
        __ vmovdqu(xmm0, Address(from, qword_count, Address::times_8, 0));
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1455
        __ vmovdqu(Address(dest, qword_count, Address::times_8, 0), xmm0);
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1456
      } else {
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1457
        __ movdqu(xmm0, Address(from, qword_count, Address::times_8, 16));
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1458
        __ movdqu(Address(dest, qword_count, Address::times_8, 16), xmm0);
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1459
        __ movdqu(xmm1, Address(from, qword_count, Address::times_8,  0));
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1460
        __ movdqu(Address(dest, qword_count, Address::times_8,  0), xmm1);
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1461
      }
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1462
      __ subptr(qword_count, 4);
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1463
      __ BIND(L_end);
16624
9dbd4b210bf9 8011102: Clear AVX registers after return from JNI call
kvn
parents: 15115
diff changeset
  1464
      if (UseAVX >= 2) {
9dbd4b210bf9 8011102: Clear AVX registers after return from JNI call
kvn
parents: 15115
diff changeset
  1465
        // clean upper bits of YMM registers
30299
1f6f7d1e0c1e 8078113: 8011102 changes may cause incorrect results
kvn
parents: 29695
diff changeset
  1466
        __ vpxor(xmm0, xmm0);
1f6f7d1e0c1e 8078113: 8011102 changes may cause incorrect results
kvn
parents: 29695
diff changeset
  1467
        __ vpxor(xmm1, xmm1);
16624
9dbd4b210bf9 8011102: Clear AVX registers after return from JNI call
kvn
parents: 15115
diff changeset
  1468
      }
1437
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1469
    } else {
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1470
      // Copy 32-bytes per iteration
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1471
      __ BIND(L_loop);
1437
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1472
      __ movq(to, Address(from, qword_count, Address::times_8, 24));
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1473
      __ movq(Address(dest, qword_count, Address::times_8, 24), to);
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1474
      __ movq(to, Address(from, qword_count, Address::times_8, 16));
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1475
      __ movq(Address(dest, qword_count, Address::times_8, 16), to);
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1476
      __ movq(to, Address(from, qword_count, Address::times_8,  8));
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1477
      __ movq(Address(dest, qword_count, Address::times_8,  8), to);
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1478
      __ movq(to, Address(from, qword_count, Address::times_8,  0));
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1479
      __ movq(Address(dest, qword_count, Address::times_8,  0), to);
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1480
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1481
      __ BIND(L_copy_bytes);
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1482
      __ subptr(qword_count, 4);
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1483
      __ jcc(Assembler::greaterEqual, L_loop);
1437
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1394
diff changeset
  1484
    }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1485
    __ addptr(qword_count, 4);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
    __ jcc(Assembler::greater, L_copy_8_bytes); // Copy trailing qwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
  // Arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
  //   aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
  //             ignored
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
  //   name    - stub name string
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
  // Inputs:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
  //   c_rarg0   - source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
  //   c_rarg1   - destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
  //   c_rarg2   - element count, treated as ssize_t, can be zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
  // If 'from' and/or 'to' are aligned on 4-, 2-, or 1-byte boundaries,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
  // we let the hardware handle it.  The one to eight bytes within words,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
  // dwords or qwords that span cache line boundaries will still be loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
  // and stored atomically.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
  // Side Effects:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
  //   disjoint_byte_copy_entry is set to the no-overlap entry point
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1506
  //   used by generate_conjoint_byte_copy().
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
  //
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1508
  address generate_disjoint_byte_copy(bool aligned, address* entry, const char *name) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
    __ align(CodeEntryAlignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
    StubCodeMark mark(this, "StubRoutines", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1513
    Label L_copy_bytes, L_copy_8_bytes, L_copy_4_bytes, L_copy_2_bytes;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
    Label L_copy_byte, L_exit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1515
    const Register from        = rdi;  // source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
    const Register to          = rsi;  // destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1517
    const Register count       = rdx;  // elements count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1518
    const Register byte_count  = rcx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
    const Register qword_count = count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
    const Register end_from    = from; // source array end address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1521
    const Register end_to      = to;   // destination array end address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
    // End pointers are inclusive, and if count is not zero they point
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1523
    // to the last unit copied:  end_to[0] := end_from[0]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
    __ enter(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
    assert_clean_int(c_rarg2, rax);    // Make sure 'count' is clean int.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1528
    if (entry != NULL) {
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1529
      *entry = __ pc();
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1530
       // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1531
      BLOCK_COMMENT("Entry:");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1532
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1533
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
    setup_arg_regs(); // from => rdi, to => rsi, count => rdx
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1535
                      // r9 and r10 may be used to save non-volatile registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1537
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1538
      // UnsafeCopyMemory page error: continue after ucm
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1539
      UnsafeCopyMemoryMark ucmm(this, !aligned, true);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1540
      // 'from', 'to' and 'count' are now valid
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1541
      __ movptr(byte_count, count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1542
      __ shrptr(count, 3); // count => qword_count
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1543
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1544
      // Copy from low to high addresses.  Use 'to' as scratch.
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1545
      __ lea(end_from, Address(from, qword_count, Address::times_8, -8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1546
      __ lea(end_to,   Address(to,   qword_count, Address::times_8, -8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1547
      __ negptr(qword_count); // make the count negative
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1548
      __ jmp(L_copy_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1549
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1550
      // Copy trailing qwords
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1551
    __ BIND(L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1552
      __ movq(rax, Address(end_from, qword_count, Address::times_8, 8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1553
      __ movq(Address(end_to, qword_count, Address::times_8, 8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1554
      __ increment(qword_count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1555
      __ jcc(Assembler::notZero, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1556
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1557
      // Check for and copy trailing dword
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1558
    __ BIND(L_copy_4_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1559
      __ testl(byte_count, 4);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1560
      __ jccb(Assembler::zero, L_copy_2_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1561
      __ movl(rax, Address(end_from, 8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1562
      __ movl(Address(end_to, 8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1563
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1564
      __ addptr(end_from, 4);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1565
      __ addptr(end_to, 4);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1566
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1567
      // Check for and copy trailing word
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1568
    __ BIND(L_copy_2_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1569
      __ testl(byte_count, 2);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1570
      __ jccb(Assembler::zero, L_copy_byte);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1571
      __ movw(rax, Address(end_from, 8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1572
      __ movw(Address(end_to, 8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1573
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1574
      __ addptr(end_from, 2);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1575
      __ addptr(end_to, 2);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1576
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1577
      // Check for and copy trailing byte
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1578
    __ BIND(L_copy_byte);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1579
      __ testl(byte_count, 1);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1580
      __ jccb(Assembler::zero, L_exit);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1581
      __ movb(rax, Address(end_from, 8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1582
      __ movb(Address(end_to, 8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1583
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1584
  __ BIND(L_exit);
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1585
    address ucme_exit_pc = __ pc();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1586
    restore_arg_regs();
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  1587
    inc_counter_np(SharedRuntime::_jbyte_array_copy_ctr); // Update counter after rscratch1 is free
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1588
    __ xorptr(rax, rax); // return 0
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  1589
    __ vzeroupper();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1590
    __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1591
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1592
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1593
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1594
      UnsafeCopyMemoryMark ucmm(this, !aligned, false, ucme_exit_pc);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1595
      // Copy in multi-bytes chunks
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1596
      copy_bytes_forward(end_from, end_to, qword_count, rax, L_copy_bytes, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1597
      __ jmp(L_copy_4_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1598
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1599
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1600
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1601
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1602
  // Arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1603
  //   aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1604
  //             ignored
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1605
  //   name    - stub name string
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1606
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1607
  // Inputs:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1608
  //   c_rarg0   - source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1609
  //   c_rarg1   - destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1610
  //   c_rarg2   - element count, treated as ssize_t, can be zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1611
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1612
  // If 'from' and/or 'to' are aligned on 4-, 2-, or 1-byte boundaries,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1613
  // we let the hardware handle it.  The one to eight bytes within words,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
  // dwords or qwords that span cache line boundaries will still be loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1615
  // and stored atomically.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1616
  //
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1617
  address generate_conjoint_byte_copy(bool aligned, address nooverlap_target,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1618
                                      address* entry, const char *name) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1619
    __ align(CodeEntryAlignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1620
    StubCodeMark mark(this, "StubRoutines", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1621
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1622
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1623
    Label L_copy_bytes, L_copy_8_bytes, L_copy_4_bytes, L_copy_2_bytes;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1624
    const Register from        = rdi;  // source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1625
    const Register to          = rsi;  // destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1626
    const Register count       = rdx;  // elements count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1627
    const Register byte_count  = rcx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1628
    const Register qword_count = count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1629
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1630
    __ enter(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1631
    assert_clean_int(c_rarg2, rax);    // Make sure 'count' is clean int.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1632
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1633
    if (entry != NULL) {
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1634
      *entry = __ pc();
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1635
      // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1636
      BLOCK_COMMENT("Entry:");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1637
    }
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1638
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1639
    array_overlap_test(nooverlap_target, Address::times_1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1640
    setup_arg_regs(); // from => rdi, to => rsi, count => rdx
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1641
                      // r9 and r10 may be used to save non-volatile registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1642
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1643
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1644
      // UnsafeCopyMemory page error: continue after ucm
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1645
      UnsafeCopyMemoryMark ucmm(this, !aligned, true);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1646
      // 'from', 'to' and 'count' are now valid
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1647
      __ movptr(byte_count, count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1648
      __ shrptr(count, 3);   // count => qword_count
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1649
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1650
      // Copy from high to low addresses.
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1651
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1652
      // Check for and copy trailing byte
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1653
      __ testl(byte_count, 1);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1654
      __ jcc(Assembler::zero, L_copy_2_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1655
      __ movb(rax, Address(from, byte_count, Address::times_1, -1));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1656
      __ movb(Address(to, byte_count, Address::times_1, -1), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1657
      __ decrement(byte_count); // Adjust for possible trailing word
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1658
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1659
      // Check for and copy trailing word
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1660
    __ BIND(L_copy_2_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1661
      __ testl(byte_count, 2);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1662
      __ jcc(Assembler::zero, L_copy_4_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1663
      __ movw(rax, Address(from, byte_count, Address::times_1, -2));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1664
      __ movw(Address(to, byte_count, Address::times_1, -2), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1665
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1666
      // Check for and copy trailing dword
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1667
    __ BIND(L_copy_4_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1668
      __ testl(byte_count, 4);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1669
      __ jcc(Assembler::zero, L_copy_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1670
      __ movl(rax, Address(from, qword_count, Address::times_8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1671
      __ movl(Address(to, qword_count, Address::times_8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1672
      __ jmp(L_copy_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1673
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1674
      // Copy trailing qwords
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1675
    __ BIND(L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1676
      __ movq(rax, Address(from, qword_count, Address::times_8, -8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1677
      __ movq(Address(to, qword_count, Address::times_8, -8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1678
      __ decrement(qword_count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1679
      __ jcc(Assembler::notZero, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1680
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1681
    restore_arg_regs();
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  1682
    inc_counter_np(SharedRuntime::_jbyte_array_copy_ctr); // Update counter after rscratch1 is free
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1683
    __ xorptr(rax, rax); // return 0
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  1684
    __ vzeroupper();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1685
    __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1686
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1687
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1688
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1689
      // UnsafeCopyMemory page error: continue after ucm
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1690
      UnsafeCopyMemoryMark ucmm(this, !aligned, true);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1691
      // Copy in multi-bytes chunks
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1692
      copy_bytes_backward(from, to, qword_count, rax, L_copy_bytes, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1693
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1694
    restore_arg_regs();
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  1695
    inc_counter_np(SharedRuntime::_jbyte_array_copy_ctr); // Update counter after rscratch1 is free
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1696
    __ xorptr(rax, rax); // return 0
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  1697
    __ vzeroupper();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1698
    __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1699
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1700
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1701
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1702
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1703
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1704
  // Arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1705
  //   aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1706
  //             ignored
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1707
  //   name    - stub name string
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1708
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1709
  // Inputs:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1710
  //   c_rarg0   - source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1711
  //   c_rarg1   - destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1712
  //   c_rarg2   - element count, treated as ssize_t, can be zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1713
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1714
  // If 'from' and/or 'to' are aligned on 4- or 2-byte boundaries, we
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1715
  // let the hardware handle it.  The two or four words within dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1716
  // or qwords that span cache line boundaries will still be loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1717
  // and stored atomically.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1718
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1719
  // Side Effects:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1720
  //   disjoint_short_copy_entry is set to the no-overlap entry point
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1721
  //   used by generate_conjoint_short_copy().
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1722
  //
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1723
  address generate_disjoint_short_copy(bool aligned, address *entry, const char *name) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1724
    __ align(CodeEntryAlignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1725
    StubCodeMark mark(this, "StubRoutines", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1726
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1727
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1728
    Label L_copy_bytes, L_copy_8_bytes, L_copy_4_bytes,L_copy_2_bytes,L_exit;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1729
    const Register from        = rdi;  // source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1730
    const Register to          = rsi;  // destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1731
    const Register count       = rdx;  // elements count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1732
    const Register word_count  = rcx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1733
    const Register qword_count = count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1734
    const Register end_from    = from; // source array end address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1735
    const Register end_to      = to;   // destination array end address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1736
    // End pointers are inclusive, and if count is not zero they point
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1737
    // to the last unit copied:  end_to[0] := end_from[0]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1738
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1739
    __ enter(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1740
    assert_clean_int(c_rarg2, rax);    // Make sure 'count' is clean int.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1741
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1742
    if (entry != NULL) {
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1743
      *entry = __ pc();
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1744
      // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1745
      BLOCK_COMMENT("Entry:");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1746
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1747
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1748
    setup_arg_regs(); // from => rdi, to => rsi, count => rdx
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1749
                      // r9 and r10 may be used to save non-volatile registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1750
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1751
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1752
      // UnsafeCopyMemory page error: continue after ucm
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1753
      UnsafeCopyMemoryMark ucmm(this, !aligned, true);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1754
      // 'from', 'to' and 'count' are now valid
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1755
      __ movptr(word_count, count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1756
      __ shrptr(count, 2); // count => qword_count
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1757
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1758
      // Copy from low to high addresses.  Use 'to' as scratch.
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1759
      __ lea(end_from, Address(from, qword_count, Address::times_8, -8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1760
      __ lea(end_to,   Address(to,   qword_count, Address::times_8, -8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1761
      __ negptr(qword_count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1762
      __ jmp(L_copy_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1763
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1764
      // Copy trailing qwords
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1765
    __ BIND(L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1766
      __ movq(rax, Address(end_from, qword_count, Address::times_8, 8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1767
      __ movq(Address(end_to, qword_count, Address::times_8, 8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1768
      __ increment(qword_count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1769
      __ jcc(Assembler::notZero, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1770
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1771
      // Original 'dest' is trashed, so we can't use it as a
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1772
      // base register for a possible trailing word copy
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1773
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1774
      // Check for and copy trailing dword
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1775
    __ BIND(L_copy_4_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1776
      __ testl(word_count, 2);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1777
      __ jccb(Assembler::zero, L_copy_2_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1778
      __ movl(rax, Address(end_from, 8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1779
      __ movl(Address(end_to, 8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1780
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1781
      __ addptr(end_from, 4);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1782
      __ addptr(end_to, 4);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1783
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1784
      // Check for and copy trailing word
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1785
    __ BIND(L_copy_2_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1786
      __ testl(word_count, 1);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1787
      __ jccb(Assembler::zero, L_exit);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1788
      __ movw(rax, Address(end_from, 8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1789
      __ movw(Address(end_to, 8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1790
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1791
  __ BIND(L_exit);
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1792
    address ucme_exit_pc = __ pc();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1793
    restore_arg_regs();
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  1794
    inc_counter_np(SharedRuntime::_jshort_array_copy_ctr); // Update counter after rscratch1 is free
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1795
    __ xorptr(rax, rax); // return 0
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  1796
    __ vzeroupper();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1797
    __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1798
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1799
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1800
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1801
      UnsafeCopyMemoryMark ucmm(this, !aligned, false, ucme_exit_pc);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1802
      // Copy in multi-bytes chunks
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1803
      copy_bytes_forward(end_from, end_to, qword_count, rax, L_copy_bytes, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1804
      __ jmp(L_copy_4_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1805
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1806
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1807
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1808
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1809
6433
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1810
  address generate_fill(BasicType t, bool aligned, const char *name) {
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1811
    __ align(CodeEntryAlignment);
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1812
    StubCodeMark mark(this, "StubRoutines", name);
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1813
    address start = __ pc();
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1814
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1815
    BLOCK_COMMENT("Entry:");
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1816
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1817
    const Register to       = c_rarg0;  // source array address
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1818
    const Register value    = c_rarg1;  // value
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1819
    const Register count    = c_rarg2;  // elements count
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1820
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1821
    __ enter(); // required for proper stackwalking of RuntimeStub frame
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1822
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1823
    __ generate_fill(t, aligned, to, value, count, rax, xmm0);
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1824
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  1825
    __ vzeroupper();
6433
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1826
    __ leave(); // required for proper stackwalking of RuntimeStub frame
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1827
    __ ret(0);
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1828
    return start;
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1829
  }
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  1830
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1831
  // Arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1832
  //   aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1833
  //             ignored
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1834
  //   name    - stub name string
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1835
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1836
  // Inputs:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1837
  //   c_rarg0   - source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1838
  //   c_rarg1   - destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1839
  //   c_rarg2   - element count, treated as ssize_t, can be zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1840
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1841
  // If 'from' and/or 'to' are aligned on 4- or 2-byte boundaries, we
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1842
  // let the hardware handle it.  The two or four words within dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1843
  // or qwords that span cache line boundaries will still be loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1844
  // and stored atomically.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1845
  //
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1846
  address generate_conjoint_short_copy(bool aligned, address nooverlap_target,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1847
                                       address *entry, const char *name) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1848
    __ align(CodeEntryAlignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1849
    StubCodeMark mark(this, "StubRoutines", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1850
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1851
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1852
    Label L_copy_bytes, L_copy_8_bytes, L_copy_4_bytes;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1853
    const Register from        = rdi;  // source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1854
    const Register to          = rsi;  // destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1855
    const Register count       = rdx;  // elements count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1856
    const Register word_count  = rcx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1857
    const Register qword_count = count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1858
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1859
    __ enter(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1860
    assert_clean_int(c_rarg2, rax);    // Make sure 'count' is clean int.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1861
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1862
    if (entry != NULL) {
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1863
      *entry = __ pc();
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1864
      // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1865
      BLOCK_COMMENT("Entry:");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1866
    }
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1867
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1868
    array_overlap_test(nooverlap_target, Address::times_2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1869
    setup_arg_regs(); // from => rdi, to => rsi, count => rdx
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1870
                      // r9 and r10 may be used to save non-volatile registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1871
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1872
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1873
      // UnsafeCopyMemory page error: continue after ucm
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1874
      UnsafeCopyMemoryMark ucmm(this, !aligned, true);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1875
      // 'from', 'to' and 'count' are now valid
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1876
      __ movptr(word_count, count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1877
      __ shrptr(count, 2); // count => qword_count
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1878
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1879
      // Copy from high to low addresses.  Use 'to' as scratch.
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1880
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1881
      // Check for and copy trailing word
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1882
      __ testl(word_count, 1);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1883
      __ jccb(Assembler::zero, L_copy_4_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1884
      __ movw(rax, Address(from, word_count, Address::times_2, -2));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1885
      __ movw(Address(to, word_count, Address::times_2, -2), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1886
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1887
     // Check for and copy trailing dword
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1888
    __ BIND(L_copy_4_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1889
      __ testl(word_count, 2);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1890
      __ jcc(Assembler::zero, L_copy_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1891
      __ movl(rax, Address(from, qword_count, Address::times_8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1892
      __ movl(Address(to, qword_count, Address::times_8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1893
      __ jmp(L_copy_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1894
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1895
      // Copy trailing qwords
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1896
    __ BIND(L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1897
      __ movq(rax, Address(from, qword_count, Address::times_8, -8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1898
      __ movq(Address(to, qword_count, Address::times_8, -8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1899
      __ decrement(qword_count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1900
      __ jcc(Assembler::notZero, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1901
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1902
    restore_arg_regs();
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  1903
    inc_counter_np(SharedRuntime::_jshort_array_copy_ctr); // Update counter after rscratch1 is free
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1904
    __ xorptr(rax, rax); // return 0
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  1905
    __ vzeroupper();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1906
    __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1907
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1908
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1909
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1910
      // UnsafeCopyMemory page error: continue after ucm
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1911
      UnsafeCopyMemoryMark ucmm(this, !aligned, true);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1912
      // Copy in multi-bytes chunks
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1913
      copy_bytes_backward(from, to, qword_count, rax, L_copy_bytes, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1914
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1915
    restore_arg_regs();
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  1916
    inc_counter_np(SharedRuntime::_jshort_array_copy_ctr); // Update counter after rscratch1 is free
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  1917
    __ xorptr(rax, rax); // return 0
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  1918
    __ vzeroupper();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1919
    __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1920
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1921
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1922
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1923
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1924
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1925
  // Arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1926
  //   aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1927
  //             ignored
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  1928
  //   is_oop  - true => oop array, so generate store check code
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1929
  //   name    - stub name string
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1930
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1931
  // Inputs:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1932
  //   c_rarg0   - source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1933
  //   c_rarg1   - destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1934
  //   c_rarg2   - element count, treated as ssize_t, can be zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1935
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1936
  // If 'from' and/or 'to' are aligned on 4-byte boundaries, we let
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1937
  // the hardware handle it.  The two dwords within qwords that span
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1938
  // cache line boundaries will still be loaded and stored atomicly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1939
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1940
  // Side Effects:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1941
  //   disjoint_int_copy_entry is set to the no-overlap entry point
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  1942
  //   used by generate_conjoint_int_oop_copy().
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1943
  //
8498
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  1944
  address generate_disjoint_int_oop_copy(bool aligned, bool is_oop, address* entry,
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  1945
                                         const char *name, bool dest_uninitialized = false) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1946
    __ align(CodeEntryAlignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1947
    StubCodeMark mark(this, "StubRoutines", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1948
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1949
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  1950
    Label L_copy_bytes, L_copy_8_bytes, L_copy_4_bytes, L_exit;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1951
    const Register from        = rdi;  // source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1952
    const Register to          = rsi;  // destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1953
    const Register count       = rdx;  // elements count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1954
    const Register dword_count = rcx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1955
    const Register qword_count = count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1956
    const Register end_from    = from; // source array end address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1957
    const Register end_to      = to;   // destination array end address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1958
    // End pointers are inclusive, and if count is not zero they point
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1959
    // to the last unit copied:  end_to[0] := end_from[0]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1960
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1961
    __ enter(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1962
    assert_clean_int(c_rarg2, rax);    // Make sure 'count' is clean int.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1963
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1964
    if (entry != NULL) {
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1965
      *entry = __ pc();
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1966
      // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  1967
      BLOCK_COMMENT("Entry:");
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  1968
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  1969
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1970
    setup_arg_regs_using_thread(); // from => rdi, to => rsi, count => rdx
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  1971
                                   // r9 is used to save r15_thread
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  1972
50728
9375184cec98 8205459: Rename Access API flag decorators
kbarrett
parents: 50699
diff changeset
  1973
    DecoratorSet decorators = IN_HEAP | IS_ARRAY | ARRAYCOPY_DISJOINT;
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  1974
    if (dest_uninitialized) {
50728
9375184cec98 8205459: Rename Access API flag decorators
kbarrett
parents: 50699
diff changeset
  1975
      decorators |= IS_DEST_UNINITIALIZED;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  1976
    }
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  1977
    if (aligned) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  1978
      decorators |= ARRAYCOPY_ALIGNED;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  1979
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  1980
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  1981
    BasicType type = is_oop ? T_OBJECT : T_INT;
49754
ee93c1087584 8201362: Remove CollectedHeap::barrier_set()
pliden
parents: 49748
diff changeset
  1982
    BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  1983
    bs->arraycopy_prologue(_masm, decorators, type, from, to, count);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  1984
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1985
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1986
      // UnsafeCopyMemory page error: continue after ucm
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1987
      UnsafeCopyMemoryMark ucmm(this, !is_oop && !aligned, true);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1988
      // 'from', 'to' and 'count' are now valid
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1989
      __ movptr(dword_count, count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1990
      __ shrptr(count, 1); // count => qword_count
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1991
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1992
      // Copy from low to high addresses.  Use 'to' as scratch.
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1993
      __ lea(end_from, Address(from, qword_count, Address::times_8, -8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1994
      __ lea(end_to,   Address(to,   qword_count, Address::times_8, -8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1995
      __ negptr(qword_count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1996
      __ jmp(L_copy_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1997
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1998
      // Copy trailing qwords
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  1999
    __ BIND(L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2000
      __ movq(rax, Address(end_from, qword_count, Address::times_8, 8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2001
      __ movq(Address(end_to, qword_count, Address::times_8, 8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2002
      __ increment(qword_count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2003
      __ jcc(Assembler::notZero, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2004
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2005
      // Check for and copy trailing dword
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2006
    __ BIND(L_copy_4_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2007
      __ testl(dword_count, 1); // Only byte test since the value is 0 or 1
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2008
      __ jccb(Assembler::zero, L_exit);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2009
      __ movl(rax, Address(end_from, 8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2010
      __ movl(Address(end_to, 8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2011
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2012
  __ BIND(L_exit);
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2013
    address ucme_exit_pc = __ pc();
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2014
    bs->arraycopy_epilogue(_masm, decorators, type, from, to, dword_count);
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2015
    restore_arg_regs_using_thread();
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2016
    inc_counter_np(SharedRuntime::_jint_array_copy_ctr); // Update counter after rscratch1 is free
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  2017
    __ vzeroupper();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2018
    __ xorptr(rax, rax); // return 0
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2019
    __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2020
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2021
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2022
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2023
      UnsafeCopyMemoryMark ucmm(this, !is_oop && !aligned, false, ucme_exit_pc);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2024
      // Copy in multi-bytes chunks
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2025
      copy_bytes_forward(end_from, end_to, qword_count, rax, L_copy_bytes, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2026
      __ jmp(L_copy_4_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2027
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2028
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2029
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2030
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2031
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2032
  // Arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2033
  //   aligned - true => Input and output aligned on a HeapWord == 8-byte boundary
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2034
  //             ignored
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2035
  //   is_oop  - true => oop array, so generate store check code
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2036
  //   name    - stub name string
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2037
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2038
  // Inputs:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2039
  //   c_rarg0   - source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2040
  //   c_rarg1   - destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2041
  //   c_rarg2   - element count, treated as ssize_t, can be zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2042
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2043
  // If 'from' and/or 'to' are aligned on 4-byte boundaries, we let
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2044
  // the hardware handle it.  The two dwords within qwords that span
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2045
  // cache line boundaries will still be loaded and stored atomicly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2046
  //
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2047
  address generate_conjoint_int_oop_copy(bool aligned, bool is_oop, address nooverlap_target,
8498
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  2048
                                         address *entry, const char *name,
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  2049
                                         bool dest_uninitialized = false) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2050
    __ align(CodeEntryAlignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2051
    StubCodeMark mark(this, "StubRoutines", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2052
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2053
51756
4bd35a5ec694 8210676: Remove some unused Label variables
mikael
parents: 50860
diff changeset
  2054
    Label L_copy_bytes, L_copy_8_bytes, L_exit;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2055
    const Register from        = rdi;  // source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2056
    const Register to          = rsi;  // destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2057
    const Register count       = rdx;  // elements count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2058
    const Register dword_count = rcx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2059
    const Register qword_count = count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2060
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2061
    __ enter(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2062
    assert_clean_int(c_rarg2, rax);    // Make sure 'count' is clean int.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2063
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2064
    if (entry != NULL) {
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2065
      *entry = __ pc();
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2066
       // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2067
      BLOCK_COMMENT("Entry:");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2068
    }
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2069
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2070
    array_overlap_test(nooverlap_target, Address::times_4);
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2071
    setup_arg_regs_using_thread(); // from => rdi, to => rsi, count => rdx
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2072
                                   // r9 is used to save r15_thread
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2073
50728
9375184cec98 8205459: Rename Access API flag decorators
kbarrett
parents: 50699
diff changeset
  2074
    DecoratorSet decorators = IN_HEAP | IS_ARRAY;
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2075
    if (dest_uninitialized) {
50728
9375184cec98 8205459: Rename Access API flag decorators
kbarrett
parents: 50699
diff changeset
  2076
      decorators |= IS_DEST_UNINITIALIZED;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2077
    }
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2078
    if (aligned) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2079
      decorators |= ARRAYCOPY_ALIGNED;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2080
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2081
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2082
    BasicType type = is_oop ? T_OBJECT : T_INT;
49754
ee93c1087584 8201362: Remove CollectedHeap::barrier_set()
pliden
parents: 49748
diff changeset
  2083
    BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2084
    // no registers are destroyed by this call
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2085
    bs->arraycopy_prologue(_masm, decorators, type, from, to, count);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2086
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2087
    assert_clean_int(count, rax); // Make sure 'count' is clean int.
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2088
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2089
      // UnsafeCopyMemory page error: continue after ucm
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2090
      UnsafeCopyMemoryMark ucmm(this, !is_oop && !aligned, true);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2091
      // 'from', 'to' and 'count' are now valid
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2092
      __ movptr(dword_count, count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2093
      __ shrptr(count, 1); // count => qword_count
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2094
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2095
      // Copy from high to low addresses.  Use 'to' as scratch.
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2096
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2097
      // Check for and copy trailing dword
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2098
      __ testl(dword_count, 1);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2099
      __ jcc(Assembler::zero, L_copy_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2100
      __ movl(rax, Address(from, dword_count, Address::times_4, -4));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2101
      __ movl(Address(to, dword_count, Address::times_4, -4), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2102
      __ jmp(L_copy_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2103
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2104
      // Copy trailing qwords
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2105
    __ BIND(L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2106
      __ movq(rax, Address(from, qword_count, Address::times_8, -8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2107
      __ movq(Address(to, qword_count, Address::times_8, -8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2108
      __ decrement(qword_count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2109
      __ jcc(Assembler::notZero, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2110
    }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2111
    if (is_oop) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2112
      __ jmp(L_exit);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2113
    }
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2114
    restore_arg_regs_using_thread();
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2115
    inc_counter_np(SharedRuntime::_jint_array_copy_ctr); // Update counter after rscratch1 is free
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2116
    __ xorptr(rax, rax); // return 0
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  2117
    __ vzeroupper();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2118
    __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2119
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2120
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2121
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2122
      // UnsafeCopyMemory page error: continue after ucm
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2123
      UnsafeCopyMemoryMark ucmm(this, !is_oop && !aligned, true);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2124
      // Copy in multi-bytes chunks
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2125
      copy_bytes_backward(from, to, qword_count, rax, L_copy_bytes, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2126
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2127
17622
4037daf22a17 8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents: 16624
diff changeset
  2128
  __ BIND(L_exit);
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2129
    bs->arraycopy_epilogue(_masm, decorators, type, from, to, dword_count);
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2130
    restore_arg_regs_using_thread();
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2131
    inc_counter_np(SharedRuntime::_jint_array_copy_ctr); // Update counter after rscratch1 is free
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2132
    __ xorptr(rax, rax); // return 0
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  2133
    __ vzeroupper();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2134
    __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2135
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2136
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2137
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2138
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2139
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2140
  // Arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2141
  //   aligned - true => Input and output aligned on a HeapWord boundary == 8 bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2142
  //             ignored
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2143
  //   is_oop  - true => oop array, so generate store check code
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2144
  //   name    - stub name string
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2145
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2146
  // Inputs:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2147
  //   c_rarg0   - source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2148
  //   c_rarg1   - destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2149
  //   c_rarg2   - element count, treated as ssize_t, can be zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2150
  //
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2151
 // Side Effects:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2152
  //   disjoint_oop_copy_entry or disjoint_long_copy_entry is set to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2153
  //   no-overlap entry point used by generate_conjoint_long_oop_copy().
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2154
  //
8498
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  2155
  address generate_disjoint_long_oop_copy(bool aligned, bool is_oop, address *entry,
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  2156
                                          const char *name, bool dest_uninitialized = false) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2157
    __ align(CodeEntryAlignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2158
    StubCodeMark mark(this, "StubRoutines", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2159
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2160
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  2161
    Label L_copy_bytes, L_copy_8_bytes, L_exit;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2162
    const Register from        = rdi;  // source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2163
    const Register to          = rsi;  // destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2164
    const Register qword_count = rdx;  // elements count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2165
    const Register end_from    = from; // source array end address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2166
    const Register end_to      = rcx;  // destination array end address
17622
4037daf22a17 8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents: 16624
diff changeset
  2167
    const Register saved_count = r11;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2168
    // End pointers are inclusive, and if count is not zero they point
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2169
    // to the last unit copied:  end_to[0] := end_from[0]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2170
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2171
    __ enter(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2172
    // Save no-overlap entry point for generate_conjoint_long_oop_copy()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2173
    assert_clean_int(c_rarg2, rax);    // Make sure 'count' is clean int.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2174
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2175
    if (entry != NULL) {
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2176
      *entry = __ pc();
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2177
      // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2178
      BLOCK_COMMENT("Entry:");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2179
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2180
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2181
    setup_arg_regs_using_thread(); // from => rdi, to => rsi, count => rdx
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2182
                                     // r9 is used to save r15_thread
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2183
    // 'from', 'to' and 'qword_count' are now valid
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2184
50728
9375184cec98 8205459: Rename Access API flag decorators
kbarrett
parents: 50699
diff changeset
  2185
    DecoratorSet decorators = IN_HEAP | IS_ARRAY | ARRAYCOPY_DISJOINT;
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2186
    if (dest_uninitialized) {
50728
9375184cec98 8205459: Rename Access API flag decorators
kbarrett
parents: 50699
diff changeset
  2187
      decorators |= IS_DEST_UNINITIALIZED;
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2188
    }
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2189
    if (aligned) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2190
      decorators |= ARRAYCOPY_ALIGNED;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2191
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2192
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2193
    BasicType type = is_oop ? T_OBJECT : T_LONG;
49754
ee93c1087584 8201362: Remove CollectedHeap::barrier_set()
pliden
parents: 49748
diff changeset
  2194
    BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2195
    bs->arraycopy_prologue(_masm, decorators, type, from, to, qword_count);
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2196
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2197
      // UnsafeCopyMemory page error: continue after ucm
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2198
      UnsafeCopyMemoryMark ucmm(this, !is_oop && !aligned, true);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2199
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2200
      // Copy from low to high addresses.  Use 'to' as scratch.
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2201
      __ lea(end_from, Address(from, qword_count, Address::times_8, -8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2202
      __ lea(end_to,   Address(to,   qword_count, Address::times_8, -8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2203
      __ negptr(qword_count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2204
      __ jmp(L_copy_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2205
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2206
      // Copy trailing qwords
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2207
    __ BIND(L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2208
      __ movq(rax, Address(end_from, qword_count, Address::times_8, 8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2209
      __ movq(Address(end_to, qword_count, Address::times_8, 8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2210
      __ increment(qword_count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2211
      __ jcc(Assembler::notZero, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2212
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2213
    if (is_oop) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2214
      __ jmp(L_exit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2215
    } else {
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2216
      restore_arg_regs_using_thread();
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2217
      inc_counter_np(SharedRuntime::_jlong_array_copy_ctr); // Update counter after rscratch1 is free
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2218
      __ xorptr(rax, rax); // return 0
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  2219
      __ vzeroupper();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2220
      __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2221
      __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2222
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2223
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2224
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2225
      // UnsafeCopyMemory page error: continue after ucm
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2226
      UnsafeCopyMemoryMark ucmm(this, !is_oop && !aligned, true);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2227
      // Copy in multi-bytes chunks
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2228
      copy_bytes_forward(end_from, end_to, qword_count, rax, L_copy_bytes, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2229
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2230
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2231
    __ BIND(L_exit);
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2232
    bs->arraycopy_epilogue(_masm, decorators, type, from, to, qword_count);
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2233
    restore_arg_regs_using_thread();
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2234
    if (is_oop) {
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2235
      inc_counter_np(SharedRuntime::_oop_array_copy_ctr); // Update counter after rscratch1 is free
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2236
    } else {
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2237
      inc_counter_np(SharedRuntime::_jlong_array_copy_ctr); // Update counter after rscratch1 is free
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2238
    }
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  2239
    __ vzeroupper();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2240
    __ xorptr(rax, rax); // return 0
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2241
    __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2242
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2243
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2244
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2245
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2246
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2247
  // Arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2248
  //   aligned - true => Input and output aligned on a HeapWord boundary == 8 bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2249
  //             ignored
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2250
  //   is_oop  - true => oop array, so generate store check code
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2251
  //   name    - stub name string
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2252
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2253
  // Inputs:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2254
  //   c_rarg0   - source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2255
  //   c_rarg1   - destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2256
  //   c_rarg2   - element count, treated as ssize_t, can be zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2257
  //
8498
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  2258
  address generate_conjoint_long_oop_copy(bool aligned, bool is_oop,
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  2259
                                          address nooverlap_target, address *entry,
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  2260
                                          const char *name, bool dest_uninitialized = false) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2261
    __ align(CodeEntryAlignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2262
    StubCodeMark mark(this, "StubRoutines", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2263
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2264
15115
f8ef87f6f07f 8005544: Use 256bit YMM registers in arraycopy stubs on x86
kvn
parents: 14834
diff changeset
  2265
    Label L_copy_bytes, L_copy_8_bytes, L_exit;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2266
    const Register from        = rdi;  // source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2267
    const Register to          = rsi;  // destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2268
    const Register qword_count = rdx;  // elements count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2269
    const Register saved_count = rcx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2270
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2271
    __ enter(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2272
    assert_clean_int(c_rarg2, rax);    // Make sure 'count' is clean int.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2273
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2274
    if (entry != NULL) {
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2275
      *entry = __ pc();
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2276
      // caller can pass a 64-bit byte count here (from Unsafe.copyMemory)
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2277
      BLOCK_COMMENT("Entry:");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2278
    }
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2279
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2280
    array_overlap_test(nooverlap_target, Address::times_8);
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2281
    setup_arg_regs_using_thread(); // from => rdi, to => rsi, count => rdx
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2282
                                   // r9 is used to save r15_thread
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2283
    // 'from', 'to' and 'qword_count' are now valid
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2284
54755
de34f4b370b0 8223244: Fix usage of ARRAYCOPY_DISJOINT decorator
rkennke
parents: 54750
diff changeset
  2285
    DecoratorSet decorators = IN_HEAP | IS_ARRAY;
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2286
    if (dest_uninitialized) {
50728
9375184cec98 8205459: Rename Access API flag decorators
kbarrett
parents: 50699
diff changeset
  2287
      decorators |= IS_DEST_UNINITIALIZED;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2288
    }
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2289
    if (aligned) {
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2290
      decorators |= ARRAYCOPY_ALIGNED;
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2291
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2292
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2293
    BasicType type = is_oop ? T_OBJECT : T_LONG;
49754
ee93c1087584 8201362: Remove CollectedHeap::barrier_set()
pliden
parents: 49748
diff changeset
  2294
    BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2295
    bs->arraycopy_prologue(_masm, decorators, type, from, to, qword_count);
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2296
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2297
      // UnsafeCopyMemory page error: continue after ucm
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2298
      UnsafeCopyMemoryMark ucmm(this, !is_oop && !aligned, true);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2299
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2300
      __ jmp(L_copy_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2301
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2302
      // Copy trailing qwords
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2303
    __ BIND(L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2304
      __ movq(rax, Address(from, qword_count, Address::times_8, -8));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2305
      __ movq(Address(to, qword_count, Address::times_8, -8), rax);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2306
      __ decrement(qword_count);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2307
      __ jcc(Assembler::notZero, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2308
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2309
    if (is_oop) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2310
      __ jmp(L_exit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2311
    } else {
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2312
      restore_arg_regs_using_thread();
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2313
      inc_counter_np(SharedRuntime::_jlong_array_copy_ctr); // Update counter after rscratch1 is free
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2314
      __ xorptr(rax, rax); // return 0
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  2315
      __ vzeroupper();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2316
      __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2317
      __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2318
    }
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2319
    {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2320
      // UnsafeCopyMemory page error: continue after ucm
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2321
      UnsafeCopyMemoryMark ucmm(this, !is_oop && !aligned, true);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2322
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2323
      // Copy in multi-bytes chunks
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2324
      copy_bytes_backward(from, to, qword_count, rax, L_copy_bytes, L_copy_8_bytes);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  2325
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2326
    __ BIND(L_exit);
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2327
    bs->arraycopy_epilogue(_masm, decorators, type, from, to, qword_count);
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2328
    restore_arg_regs_using_thread();
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2329
    if (is_oop) {
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2330
      inc_counter_np(SharedRuntime::_oop_array_copy_ctr); // Update counter after rscratch1 is free
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2331
    } else {
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2332
      inc_counter_np(SharedRuntime::_jlong_array_copy_ctr); // Update counter after rscratch1 is free
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2333
    }
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  2334
    __ vzeroupper();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2335
    __ xorptr(rax, rax); // return 0
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2336
    __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2337
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2338
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2339
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2340
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2341
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2342
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2343
  // Helper for generating a dynamic type check.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2344
  // Smashes no registers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2345
  void generate_type_check(Register sub_klass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2346
                           Register super_check_offset,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2347
                           Register super_klass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2348
                           Label& L_success) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2349
    assert_different_registers(sub_klass, super_check_offset, super_klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2350
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2351
    BLOCK_COMMENT("type_check:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2352
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2353
    Label L_miss;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2354
2256
82d4e10b7c6b 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 1888
diff changeset
  2355
    __ check_klass_subtype_fast_path(sub_klass, super_klass, noreg,        &L_success, &L_miss, NULL,
82d4e10b7c6b 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 1888
diff changeset
  2356
                                     super_check_offset);
82d4e10b7c6b 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 1888
diff changeset
  2357
    __ check_klass_subtype_slow_path(sub_klass, super_klass, noreg, noreg, &L_success, NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2358
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2359
    // Fall through on failure!
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2360
    __ BIND(L_miss);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2361
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2362
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2363
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2364
  //  Generate checkcasting array copy stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2365
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2366
  //  Input:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2367
  //    c_rarg0   - source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2368
  //    c_rarg1   - destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2369
  //    c_rarg2   - element count, treated as ssize_t, can be zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2370
  //    c_rarg3   - size_t ckoff (super_check_offset)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2371
  // not Win64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2372
  //    c_rarg4   - oop ckval (super_klass)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2373
  // Win64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2374
  //    rsp+40    - oop ckval (super_klass)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2375
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2376
  //  Output:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2377
  //    rax ==  0  -  success
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2378
  //    rax == -1^K - failure, where K is partial transfer count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2379
  //
8498
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  2380
  address generate_checkcast_copy(const char *name, address *entry,
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  2381
                                  bool dest_uninitialized = false) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2382
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2383
    Label L_load_element, L_store_element, L_do_card_marks, L_done;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2384
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2385
    // Input registers (after setup_arg_regs)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2386
    const Register from        = rdi;   // source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2387
    const Register to          = rsi;   // destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2388
    const Register length      = rdx;   // elements count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2389
    const Register ckoff       = rcx;   // super_check_offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2390
    const Register ckval       = r8;    // super_klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2391
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2392
    // Registers used as temps (r13, r14 are save-on-entry)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2393
    const Register end_from    = from;  // source array end address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2394
    const Register end_to      = r13;   // destination array end address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2395
    const Register count       = rdx;   // -(count_remaining)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2396
    const Register r14_length  = r14;   // saved copy of length
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2397
    // End pointers are inclusive, and if length is not zero they point
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2398
    // to the last unit copied:  end_to[0] := end_from[0]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2399
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2400
    const Register rax_oop    = rax;    // actual oop copied
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2401
    const Register r11_klass  = r11;    // oop._klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2402
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2403
    //---------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2404
    // Assembler stub will be used for this call to arraycopy
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2405
    // if the two arrays are subtypes of Object[] but the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2406
    // destination array type is not equal to or a supertype
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2407
    // of the source type.  Each element must be separately
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2408
    // checked.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2409
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2410
    __ align(CodeEntryAlignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2411
    StubCodeMark mark(this, "StubRoutines", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2412
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2413
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2414
    __ enter(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2415
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2416
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2417
    // caller guarantees that the arrays really are different
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2418
    // otherwise, we would have to make conjoint checks
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2419
    { Label L;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2420
      array_overlap_test(L, TIMES_OOP);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2421
      __ stop("checkcast_copy within a single array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2422
      __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2423
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2424
#endif //ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2425
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2426
    setup_arg_regs(4); // from => rdi, to => rsi, length => rdx
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2427
                       // ckoff => rcx, ckval => r8
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2428
                       // r9 and r10 may be used to save non-volatile registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2429
#ifdef _WIN64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2430
    // last argument (#4) is on stack on Win64
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2431
    __ movptr(ckval, Address(rsp, 6 * wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2432
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2433
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2434
    // Caller of this entry point must set up the argument registers.
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2435
    if (entry != NULL) {
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2436
      *entry = __ pc();
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2437
      BLOCK_COMMENT("Entry:");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2438
    }
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2439
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2440
    // allocate spill slots for r13, r14
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2441
    enum {
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2442
      saved_r13_offset,
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2443
      saved_r14_offset,
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2444
      saved_r10_offset,
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2445
      saved_rbp_offset
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2446
    };
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2447
    __ subptr(rsp, saved_rbp_offset * wordSize);
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2448
    __ movptr(Address(rsp, saved_r13_offset * wordSize), r13);
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2449
    __ movptr(Address(rsp, saved_r14_offset * wordSize), r14);
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2450
    __ movptr(Address(rsp, saved_r10_offset * wordSize), r10);
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2451
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2452
#ifdef ASSERT
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2453
      Label L2;
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2454
      __ get_thread(r14);
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2455
      __ cmpptr(r15_thread, r14);
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2456
      __ jcc(Assembler::equal, L2);
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2457
      __ stop("StubRoutines::call_stub: r15_thread is modified by call");
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2458
      __ bind(L2);
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2459
#endif // ASSERT
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2460
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2461
    // check that int operands are properly extended to size_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2462
    assert_clean_int(length, rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2463
    assert_clean_int(ckoff, rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2464
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2465
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2466
    BLOCK_COMMENT("assert consistent ckoff/ckval");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2467
    // The ckoff and ckval must be mutually consistent,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2468
    // even though caller generates both.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2469
    { Label L;
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 11194
diff changeset
  2470
      int sco_offset = in_bytes(Klass::super_check_offset_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2471
      __ cmpl(ckoff, Address(ckval, sco_offset));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2472
      __ jcc(Assembler::equal, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2473
      __ stop("super_check_offset inconsistent");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2474
      __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2475
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2476
#endif //ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2477
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2478
    // Loop-invariant addresses.  They are exclusive end pointers.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2479
    Address end_from_addr(from, length, TIMES_OOP, 0);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2480
    Address   end_to_addr(to,   length, TIMES_OOP, 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2481
    // Loop-variant addresses.  They assume post-incremented count < 0.
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2482
    Address from_element_addr(end_from, count, TIMES_OOP, 0);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2483
    Address   to_element_addr(end_to,   count, TIMES_OOP, 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2484
54755
de34f4b370b0 8223244: Fix usage of ARRAYCOPY_DISJOINT decorator
rkennke
parents: 54750
diff changeset
  2485
    DecoratorSet decorators = IN_HEAP | IS_ARRAY | ARRAYCOPY_CHECKCAST | ARRAYCOPY_DISJOINT;
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2486
    if (dest_uninitialized) {
50728
9375184cec98 8205459: Rename Access API flag decorators
kbarrett
parents: 50699
diff changeset
  2487
      decorators |= IS_DEST_UNINITIALIZED;
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2488
    }
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2489
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2490
    BasicType type = T_OBJECT;
49754
ee93c1087584 8201362: Remove CollectedHeap::barrier_set()
pliden
parents: 49748
diff changeset
  2491
    BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2492
    bs->arraycopy_prologue(_masm, decorators, type, from, to, count);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2493
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2494
    // Copy from low to high addresses, indexed from the end of each array.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2495
    __ lea(end_from, end_from_addr);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2496
    __ lea(end_to,   end_to_addr);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2497
    __ movptr(r14_length, length);        // save a copy of the length
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2498
    assert(length == count, "");          // else fix next line:
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2499
    __ negptr(count);                     // negate and test the length
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2500
    __ jcc(Assembler::notZero, L_load_element);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2501
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2502
    // Empty array:  Nothing to do.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2503
    __ xorptr(rax, rax);                  // return 0 on (trivial) success
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2504
    __ jmp(L_done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2505
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2506
    // ======== begin loop ========
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2507
    // (Loop is rotated; its entry is L_load_element.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2508
    // Loop control:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2509
    //   for (count = -count; count != 0; count++)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2510
    // Base pointers src, dst are biased by 8*(count-1),to last element.
5249
5cac34e6fe54 6940701: Don't align loops in stubs for Niagara sparc
kvn
parents: 5050
diff changeset
  2511
    __ align(OptoLoopAlignment);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2512
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2513
    __ BIND(L_store_element);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
  2514
    __ store_heap_oop(to_element_addr, rax_oop, noreg, noreg, AS_RAW);  // store the oop
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2515
    __ increment(count);               // increment the count toward zero
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2516
    __ jcc(Assembler::zero, L_do_card_marks);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2517
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2518
    // ======== loop entry is here ========
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2519
    __ BIND(L_load_element);
49748
6a880e576856 8199417: Modularize interpreter GC barriers
eosterlund
parents: 49484
diff changeset
  2520
    __ load_heap_oop(rax_oop, from_element_addr, noreg, noreg, AS_RAW); // load the oop
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2521
    __ testptr(rax_oop, rax_oop);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2522
    __ jcc(Assembler::zero, L_store_element);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2523
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2524
    __ load_klass(r11_klass, rax_oop);// query the object klass
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2525
    generate_type_check(r11_klass, ckoff, ckval, L_store_element);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2526
    // ======== end loop ========
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2527
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2528
    // It was a real error; we must depend on the caller to finish the job.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2529
    // Register rdx = -1 * number of *remaining* oops, r14 = *total* oops.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2530
    // Emit GC store barriers for the oops we have copied (r14 + rdx),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2531
    // and report their number to the caller.
17622
4037daf22a17 8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents: 16624
diff changeset
  2532
    assert_different_registers(rax, r14_length, count, to, end_to, rcx, rscratch1);
4037daf22a17 8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents: 16624
diff changeset
  2533
    Label L_post_barrier;
4037daf22a17 8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents: 16624
diff changeset
  2534
    __ addptr(r14_length, count);     // K = (original - remaining) oops
4037daf22a17 8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents: 16624
diff changeset
  2535
    __ movptr(rax, r14_length);       // save the value
4037daf22a17 8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents: 16624
diff changeset
  2536
    __ notptr(rax);                   // report (-1^K) to caller (does not affect flags)
4037daf22a17 8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents: 16624
diff changeset
  2537
    __ jccb(Assembler::notZero, L_post_barrier);
4037daf22a17 8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents: 16624
diff changeset
  2538
    __ jmp(L_done); // K == 0, nothing was copied, skip post barrier
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2539
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2540
    // Come here on success only.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2541
    __ BIND(L_do_card_marks);
17622
4037daf22a17 8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents: 16624
diff changeset
  2542
    __ xorptr(rax, rax);              // return 0 on success
4037daf22a17 8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents: 16624
diff changeset
  2543
4037daf22a17 8010927: Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
kvn
parents: 16624
diff changeset
  2544
    __ BIND(L_post_barrier);
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
  2545
    bs->arraycopy_epilogue(_masm, decorators, type, from, to, r14_length);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2546
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2547
    // Common exit point (success or failure).
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2548
    __ BIND(L_done);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2549
    __ movptr(r13, Address(rsp, saved_r13_offset * wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2550
    __ movptr(r14, Address(rsp, saved_r14_offset * wordSize));
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  2551
    __ movptr(r10, Address(rsp, saved_r10_offset * wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2552
    restore_arg_regs();
11194
ee1235a09fc3 7110489: C1: 64-bit tiered with ForceUnreachable: assert(reachable(src)) failed: Address should be reachable
never
parents: 11190
diff changeset
  2553
    inc_counter_np(SharedRuntime::_checkcast_array_copy_ctr); // Update counter after rscratch1 is free
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2554
    __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2555
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2556
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2557
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2558
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2559
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2560
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2561
  //  Generate 'unsafe' array copy stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2562
  //  Though just as safe as the other stubs, it takes an unscaled
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2563
  //  size_t argument instead of an element count.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2564
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2565
  //  Input:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2566
  //    c_rarg0   - source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2567
  //    c_rarg1   - destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2568
  //    c_rarg2   - byte count, treated as ssize_t, can be zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2569
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2570
  // Examines the alignment of the operands and dispatches
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2571
  // to a long, int, short, or byte copy loop.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2572
  //
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2573
  address generate_unsafe_copy(const char *name,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2574
                               address byte_copy_entry, address short_copy_entry,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2575
                               address int_copy_entry, address long_copy_entry) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2576
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2577
    Label L_long_aligned, L_int_aligned, L_short_aligned;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2578
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2579
    // Input registers (before setup_arg_regs)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2580
    const Register from        = c_rarg0;  // source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2581
    const Register to          = c_rarg1;  // destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2582
    const Register size        = c_rarg2;  // byte count (size_t)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2583
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2584
    // Register used as a temp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2585
    const Register bits        = rax;      // test copy of low bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2586
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2587
    __ align(CodeEntryAlignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2588
    StubCodeMark mark(this, "StubRoutines", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2589
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2590
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2591
    __ enter(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2592
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2593
    // bump this on entry, not on exit:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2594
    inc_counter_np(SharedRuntime::_unsafe_array_copy_ctr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2595
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2596
    __ mov(bits, from);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2597
    __ orptr(bits, to);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2598
    __ orptr(bits, size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2599
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2600
    __ testb(bits, BytesPerLong-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2601
    __ jccb(Assembler::zero, L_long_aligned);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2602
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2603
    __ testb(bits, BytesPerInt-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2604
    __ jccb(Assembler::zero, L_int_aligned);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2605
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2606
    __ testb(bits, BytesPerShort-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2607
    __ jump_cc(Assembler::notZero, RuntimeAddress(byte_copy_entry));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2608
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2609
    __ BIND(L_short_aligned);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2610
    __ shrptr(size, LogBytesPerShort); // size => short_count
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2611
    __ jump(RuntimeAddress(short_copy_entry));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2612
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2613
    __ BIND(L_int_aligned);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2614
    __ shrptr(size, LogBytesPerInt); // size => int_count
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2615
    __ jump(RuntimeAddress(int_copy_entry));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2616
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2617
    __ BIND(L_long_aligned);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2618
    __ shrptr(size, LogBytesPerLong); // size => qword_count
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2619
    __ jump(RuntimeAddress(long_copy_entry));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2620
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2621
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2622
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2623
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2624
  // Perform range checks on the proposed arraycopy.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2625
  // Kills temp, but nothing else.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2626
  // Also, clean the sign bits of src_pos and dst_pos.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2627
  void arraycopy_range_checks(Register src,     // source array oop (c_rarg0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2628
                              Register src_pos, // source position (c_rarg1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2629
                              Register dst,     // destination array oo (c_rarg2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2630
                              Register dst_pos, // destination position (c_rarg3)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2631
                              Register length,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2632
                              Register temp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2633
                              Label& L_failed) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2634
    BLOCK_COMMENT("arraycopy_range_checks:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2635
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2636
    //  if (src_pos + length > arrayOop(src)->length())  FAIL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2637
    __ movl(temp, length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2638
    __ addl(temp, src_pos);             // src_pos + length
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2639
    __ cmpl(temp, Address(src, arrayOopDesc::length_offset_in_bytes()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2640
    __ jcc(Assembler::above, L_failed);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2641
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2642
    //  if (dst_pos + length > arrayOop(dst)->length())  FAIL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2643
    __ movl(temp, length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2644
    __ addl(temp, dst_pos);             // dst_pos + length
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2645
    __ cmpl(temp, Address(dst, arrayOopDesc::length_offset_in_bytes()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2646
    __ jcc(Assembler::above, L_failed);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2647
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2648
    // Have to clean up high 32-bits of 'src_pos' and 'dst_pos'.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2649
    // Move with sign extension can be used since they are positive.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2650
    __ movslq(src_pos, src_pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2651
    __ movslq(dst_pos, dst_pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2652
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2653
    BLOCK_COMMENT("arraycopy_range_checks done");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2654
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2655
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2656
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2657
  //  Generate generic array copy stubs
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2658
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2659
  //  Input:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2660
  //    c_rarg0    -  src oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2661
  //    c_rarg1    -  src_pos (32-bits)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2662
  //    c_rarg2    -  dst oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2663
  //    c_rarg3    -  dst_pos (32-bits)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2664
  // not Win64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2665
  //    c_rarg4    -  element count (32-bits)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2666
  // Win64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2667
  //    rsp+40     -  element count (32-bits)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2668
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2669
  //  Output:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2670
  //    rax ==  0  -  success
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2671
  //    rax == -1^K - failure, where K is partial transfer count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2672
  //
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2673
  address generate_generic_copy(const char *name,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  2674
                                address byte_copy_entry, address short_copy_entry,
8876
f82367de21f5 7026307: DEBUG MESSAGE: broken null klass on amd64
iveresov
parents: 8874
diff changeset
  2675
                                address int_copy_entry, address oop_copy_entry,
f82367de21f5 7026307: DEBUG MESSAGE: broken null klass on amd64
iveresov
parents: 8874
diff changeset
  2676
                                address long_copy_entry, address checkcast_copy_entry) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2677
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2678
    Label L_failed, L_failed_0, L_objArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2679
    Label L_copy_bytes, L_copy_shorts, L_copy_ints, L_copy_longs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2680
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2681
    // Input registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2682
    const Register src        = c_rarg0;  // source array oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2683
    const Register src_pos    = c_rarg1;  // source position
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2684
    const Register dst        = c_rarg2;  // destination array oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2685
    const Register dst_pos    = c_rarg3;  // destination position
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2686
#ifndef _WIN64
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2687
    const Register length     = c_rarg4;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2688
#else
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2689
    const Address  length(rsp, 6 * wordSize);  // elements count is on stack on Win64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2690
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2691
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2692
    { int modulus = CodeEntryAlignment;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2693
      int target  = modulus - 5; // 5 = sizeof jmp(L_failed)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2694
      int advance = target - (__ offset() % modulus);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2695
      if (advance < 0)  advance += modulus;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2696
      if (advance > 0)  __ nop(advance);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2697
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2698
    StubCodeMark mark(this, "StubRoutines", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2699
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2700
    // Short-hop target to L_failed.  Makes for denser prologue code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2701
    __ BIND(L_failed_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2702
    __ jmp(L_failed);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2703
    assert(__ offset() % CodeEntryAlignment == 0, "no further alignment needed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2704
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2705
    __ align(CodeEntryAlignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2706
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2707
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2708
    __ enter(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2709
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2710
    // bump this on entry, not on exit:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2711
    inc_counter_np(SharedRuntime::_generic_array_copy_ctr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2712
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2713
    //-----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2714
    // Assembler stub will be used for this call to arraycopy
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2715
    // if the following conditions are met:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2716
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2717
    // (1) src and dst must not be null.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2718
    // (2) src_pos must not be negative.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2719
    // (3) dst_pos must not be negative.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2720
    // (4) length  must not be negative.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2721
    // (5) src klass and dst klass should be the same and not NULL.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2722
    // (6) src and dst should be arrays.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2723
    // (7) src_pos + length must not exceed length of src.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2724
    // (8) dst_pos + length must not exceed length of dst.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2725
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2726
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2727
    //  if (src == NULL) return -1;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2728
    __ testptr(src, src);         // src oop
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2729
    size_t j1off = __ offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2730
    __ jccb(Assembler::zero, L_failed_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2731
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2732
    //  if (src_pos < 0) return -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2733
    __ testl(src_pos, src_pos); // src_pos (32-bits)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2734
    __ jccb(Assembler::negative, L_failed_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2735
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2736
    //  if (dst == NULL) return -1;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2737
    __ testptr(dst, dst);         // dst oop
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2738
    __ jccb(Assembler::zero, L_failed_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2739
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2740
    //  if (dst_pos < 0) return -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2741
    __ testl(dst_pos, dst_pos); // dst_pos (32-bits)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2742
    size_t j4off = __ offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2743
    __ jccb(Assembler::negative, L_failed_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2744
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2745
    // The first four tests are very dense code,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2746
    // but not quite dense enough to put four
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2747
    // jumps in a 16-byte instruction fetch buffer.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2748
    // That's good, because some branch predicters
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2749
    // do not like jumps so close together.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2750
    // Make sure of this.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2751
    guarantee(((j1off ^ j4off) & ~15) != 0, "I$ line of 1st & 4th jumps");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2752
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2753
    // registers used as temp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2754
    const Register r11_length    = r11; // elements count to copy
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2755
    const Register r10_src_klass = r10; // array klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2756
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2757
    //  if (length < 0) return -1;
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2758
    __ movl(r11_length, length);        // length (elements count, 32-bits value)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2759
    __ testl(r11_length, r11_length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2760
    __ jccb(Assembler::negative, L_failed_0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2761
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2762
    __ load_klass(r10_src_klass, src);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2763
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2764
    //  assert(src->klass() != NULL);
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2765
    {
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2766
      BLOCK_COMMENT("assert klasses not null {");
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2767
      Label L1, L2;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2768
      __ testptr(r10_src_klass, r10_src_klass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2769
      __ jcc(Assembler::notZero, L2);   // it is broken if klass is NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2770
      __ bind(L1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2771
      __ stop("broken null klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2772
      __ bind(L2);
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2773
      __ load_klass(rax, dst);
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2774
      __ cmpq(rax, 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2775
      __ jcc(Assembler::equal, L1);     // this would be broken also
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2776
      BLOCK_COMMENT("} assert klasses not null done");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2777
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2778
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2779
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2780
    // Load layout helper (32-bits)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2781
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2782
    //  |array_tag|     | header_size | element_type |     |log2_element_size|
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2783
    // 32        30    24            16              8     2                 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2784
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2785
    //   array_tag: typeArray = 0x3, objArray = 0x2, non-array = 0x0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2786
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2787
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 11194
diff changeset
  2788
    const int lh_offset = in_bytes(Klass::layout_helper_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2789
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2790
    // Handle objArrays completely differently...
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2791
    const jint objArray_lh = Klass::array_layout_helper(T_OBJECT);
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2792
    __ cmpl(Address(r10_src_klass, lh_offset), objArray_lh);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2793
    __ jcc(Assembler::equal, L_objArray);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2794
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2795
    //  if (src->klass() != dst->klass()) return -1;
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2796
    __ load_klass(rax, dst);
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2797
    __ cmpq(r10_src_klass, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2798
    __ jcc(Assembler::notEqual, L_failed);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2799
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2800
    const Register rax_lh = rax;  // layout helper
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2801
    __ movl(rax_lh, Address(r10_src_klass, lh_offset));
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2802
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2803
    //  if (!src->is_Array()) return -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2804
    __ cmpl(rax_lh, Klass::_lh_neutral_value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2805
    __ jcc(Assembler::greaterEqual, L_failed);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2806
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2807
    // At this point, it is known to be a typeArray (array_tag 0x3).
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2808
#ifdef ASSERT
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2809
    {
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2810
      BLOCK_COMMENT("assert primitive array {");
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2811
      Label L;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2812
      __ cmpl(rax_lh, (Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2813
      __ jcc(Assembler::greaterEqual, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2814
      __ stop("must be a primitive array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2815
      __ bind(L);
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2816
      BLOCK_COMMENT("} assert primitive array done");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2817
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2818
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2819
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2820
    arraycopy_range_checks(src, src_pos, dst, dst_pos, r11_length,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2821
                           r10, L_failed);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2822
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
  2823
    // TypeArrayKlass
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2824
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2825
    // src_addr = (src + array_header_in_bytes()) + (src_pos << log2elemsize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2826
    // dst_addr = (dst + array_header_in_bytes()) + (dst_pos << log2elemsize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2827
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2828
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2829
    const Register r10_offset = r10;    // array offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2830
    const Register rax_elsize = rax_lh; // element size
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2831
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2832
    __ movl(r10_offset, rax_lh);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2833
    __ shrl(r10_offset, Klass::_lh_header_size_shift);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2834
    __ andptr(r10_offset, Klass::_lh_header_size_mask);   // array_offset
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2835
    __ addptr(src, r10_offset);           // src array offset
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2836
    __ addptr(dst, r10_offset);           // dst array offset
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2837
    BLOCK_COMMENT("choose copy loop based on element size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2838
    __ andl(rax_lh, Klass::_lh_log2_element_size_mask); // rax_lh -> rax_elsize
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2839
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2840
    // next registers should be set before the jump to corresponding stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2841
    const Register from     = c_rarg0;  // source array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2842
    const Register to       = c_rarg1;  // destination array address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2843
    const Register count    = c_rarg2;  // elements count
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2844
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2845
    // 'from', 'to', 'count' registers should be set in such order
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2846
    // since they are the same as 'src', 'src_pos', 'dst'.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2847
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2848
  __ BIND(L_copy_bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2849
    __ cmpl(rax_elsize, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2850
    __ jccb(Assembler::notEqual, L_copy_shorts);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2851
    __ lea(from, Address(src, src_pos, Address::times_1, 0));// src_addr
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2852
    __ lea(to,   Address(dst, dst_pos, Address::times_1, 0));// dst_addr
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2853
    __ movl2ptr(count, r11_length); // length
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2854
    __ jump(RuntimeAddress(byte_copy_entry));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2855
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2856
  __ BIND(L_copy_shorts);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2857
    __ cmpl(rax_elsize, LogBytesPerShort);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2858
    __ jccb(Assembler::notEqual, L_copy_ints);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2859
    __ lea(from, Address(src, src_pos, Address::times_2, 0));// src_addr
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2860
    __ lea(to,   Address(dst, dst_pos, Address::times_2, 0));// dst_addr
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2861
    __ movl2ptr(count, r11_length); // length
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2862
    __ jump(RuntimeAddress(short_copy_entry));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2863
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2864
  __ BIND(L_copy_ints);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2865
    __ cmpl(rax_elsize, LogBytesPerInt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2866
    __ jccb(Assembler::notEqual, L_copy_longs);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2867
    __ lea(from, Address(src, src_pos, Address::times_4, 0));// src_addr
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2868
    __ lea(to,   Address(dst, dst_pos, Address::times_4, 0));// dst_addr
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2869
    __ movl2ptr(count, r11_length); // length
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2870
    __ jump(RuntimeAddress(int_copy_entry));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2871
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2872
  __ BIND(L_copy_longs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2873
#ifdef ASSERT
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2874
    {
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2875
      BLOCK_COMMENT("assert long copy {");
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2876
      Label L;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2877
      __ cmpl(rax_elsize, LogBytesPerLong);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2878
      __ jcc(Assembler::equal, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2879
      __ stop("must be long copy, but elsize is wrong");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2880
      __ bind(L);
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2881
      BLOCK_COMMENT("} assert long copy done");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2882
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2883
#endif
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2884
    __ lea(from, Address(src, src_pos, Address::times_8, 0));// src_addr
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2885
    __ lea(to,   Address(dst, dst_pos, Address::times_8, 0));// dst_addr
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2886
    __ movl2ptr(count, r11_length); // length
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2887
    __ jump(RuntimeAddress(long_copy_entry));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2888
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
  2889
    // ObjArrayKlass
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2890
  __ BIND(L_objArray);
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2891
    // live at this point:  r10_src_klass, r11_length, src[_pos], dst[_pos]
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2892
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2893
    Label L_plain_copy, L_checkcast_copy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2894
    //  test array classes for subtyping
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2895
    __ load_klass(rax, dst);
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2896
    __ cmpq(r10_src_klass, rax); // usual case is exact equality
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2897
    __ jcc(Assembler::notEqual, L_checkcast_copy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2898
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2899
    // Identically typed arrays can be copied without element-wise checks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2900
    arraycopy_range_checks(src, src_pos, dst, dst_pos, r11_length,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2901
                           r10, L_failed);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2902
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2903
    __ lea(from, Address(src, src_pos, TIMES_OOP,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2904
                 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); // src_addr
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2905
    __ lea(to,   Address(dst, dst_pos, TIMES_OOP,
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2906
                 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); // dst_addr
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2907
    __ movl2ptr(count, r11_length); // length
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2908
  __ BIND(L_plain_copy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2909
    __ jump(RuntimeAddress(oop_copy_entry));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2910
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2911
  __ BIND(L_checkcast_copy);
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2912
    // live at this point:  r10_src_klass, r11_length, rax (dst_klass)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2913
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2914
      // Before looking at dst.length, make sure dst is also an objArray.
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2915
      __ cmpl(Address(rax, lh_offset), objArray_lh);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2916
      __ jcc(Assembler::notEqual, L_failed);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2917
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2918
      // It is safe to examine both src.length and dst.length.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2919
      arraycopy_range_checks(src, src_pos, dst, dst_pos, r11_length,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2920
                             rax, L_failed);
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2921
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2922
      const Register r11_dst_klass = r11;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  2923
      __ load_klass(r11_dst_klass, dst); // reload
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2924
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2925
      // Marshal the base address arguments now, freeing registers.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2926
      __ lea(from, Address(src, src_pos, TIMES_OOP,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2927
                   arrayOopDesc::base_offset_in_bytes(T_OBJECT)));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2928
      __ lea(to,   Address(dst, dst_pos, TIMES_OOP,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2929
                   arrayOopDesc::base_offset_in_bytes(T_OBJECT)));
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2930
      __ movl(count, length);           // length (reloaded)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2931
      Register sco_temp = c_rarg3;      // this register is free now
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2932
      assert_different_registers(from, to, count, sco_temp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2933
                                 r11_dst_klass, r10_src_klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2934
      assert_clean_int(count, sco_temp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2935
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2936
      // Generate the type check.
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 11194
diff changeset
  2937
      const int sco_offset = in_bytes(Klass::super_check_offset_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2938
      __ movl(sco_temp, Address(r11_dst_klass, sco_offset));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2939
      assert_clean_int(sco_temp, rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2940
      generate_type_check(r10_src_klass, sco_temp, r11_dst_klass, L_plain_copy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2941
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
  2942
      // Fetch destination element klass from the ObjArrayKlass header.
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13728
diff changeset
  2943
      int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset());
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2944
      __ movptr(r11_dst_klass, Address(r11_dst_klass, ek_offset));
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2945
      __ movl(  sco_temp,      Address(r11_dst_klass, sco_offset));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2946
      assert_clean_int(sco_temp, rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2947
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2948
      // the checkcast_copy loop needs two extra arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2949
      assert(c_rarg3 == sco_temp, "#3 already in place");
7431
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2950
      // Set up arguments for checkcast_copy_entry.
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2951
      setup_arg_regs(4);
e9f07f8aef47 6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents: 7397
diff changeset
  2952
      __ movptr(r8, r11_dst_klass);  // dst.klass.element_klass, r8 is c_rarg4 on Linux/Solaris
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2953
      __ jump(RuntimeAddress(checkcast_copy_entry));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2954
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2955
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2956
  __ BIND(L_failed);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2957
    __ xorptr(rax, rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  2958
    __ notptr(rax); // return -1
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2959
    __ leave();   // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2960
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2961
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2962
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2963
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2964
57804
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2965
  address generate_data_cache_writeback() {
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2966
    const Register src        = c_rarg0;  // source address
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2967
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2968
    __ align(CodeEntryAlignment);
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2969
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2970
    StubCodeMark mark(this, "StubRoutines", "_data_cache_writeback");
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2971
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2972
    address start = __ pc();
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2973
    __ enter();
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2974
    __ cache_wb(Address(src, 0));
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2975
    __ leave();
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2976
    __ ret(0);
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2977
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2978
    return start;
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2979
  }
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2980
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2981
  address generate_data_cache_writeback_sync() {
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2982
    const Register is_pre    = c_rarg0;  // pre or post sync
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2983
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2984
    __ align(CodeEntryAlignment);
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2985
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2986
    StubCodeMark mark(this, "StubRoutines", "_data_cache_writeback_sync");
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2987
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2988
    // pre wbsync is a no-op
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2989
    // post wbsync translates to an sfence
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2990
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2991
    Label skip;
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2992
    address start = __ pc();
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2993
    __ enter();
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2994
    __ cmpl(is_pre, 0);
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2995
    __ jcc(Assembler::notEqual, skip);
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2996
    __ cache_wbsync(false);
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2997
    __ bind(skip);
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2998
    __ leave();
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  2999
    __ ret(0);
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  3000
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  3001
    return start;
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  3002
  }
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  3003
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3004
  void generate_arraycopy_stubs() {
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3005
    address entry;
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3006
    address entry_jbyte_arraycopy;
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3007
    address entry_jshort_arraycopy;
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3008
    address entry_jint_arraycopy;
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3009
    address entry_oop_arraycopy;
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3010
    address entry_jlong_arraycopy;
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3011
    address entry_checkcast_arraycopy;
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3012
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3013
    StubRoutines::_jbyte_disjoint_arraycopy  = generate_disjoint_byte_copy(false, &entry,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3014
                                                                           "jbyte_disjoint_arraycopy");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3015
    StubRoutines::_jbyte_arraycopy           = generate_conjoint_byte_copy(false, entry, &entry_jbyte_arraycopy,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3016
                                                                           "jbyte_arraycopy");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3017
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3018
    StubRoutines::_jshort_disjoint_arraycopy = generate_disjoint_short_copy(false, &entry,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3019
                                                                            "jshort_disjoint_arraycopy");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3020
    StubRoutines::_jshort_arraycopy          = generate_conjoint_short_copy(false, entry, &entry_jshort_arraycopy,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3021
                                                                            "jshort_arraycopy");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3022
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3023
    StubRoutines::_jint_disjoint_arraycopy   = generate_disjoint_int_oop_copy(false, false, &entry,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3024
                                                                              "jint_disjoint_arraycopy");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3025
    StubRoutines::_jint_arraycopy            = generate_conjoint_int_oop_copy(false, false, entry,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3026
                                                                              &entry_jint_arraycopy, "jint_arraycopy");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3027
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3028
    StubRoutines::_jlong_disjoint_arraycopy  = generate_disjoint_long_oop_copy(false, false, &entry,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3029
                                                                               "jlong_disjoint_arraycopy");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3030
    StubRoutines::_jlong_arraycopy           = generate_conjoint_long_oop_copy(false, false, entry,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3031
                                                                               &entry_jlong_arraycopy, "jlong_arraycopy");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3032
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  3033
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  3034
    if (UseCompressedOops) {
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3035
      StubRoutines::_oop_disjoint_arraycopy  = generate_disjoint_int_oop_copy(false, true, &entry,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3036
                                                                              "oop_disjoint_arraycopy");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3037
      StubRoutines::_oop_arraycopy           = generate_conjoint_int_oop_copy(false, true, entry,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3038
                                                                              &entry_oop_arraycopy, "oop_arraycopy");
8498
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3039
      StubRoutines::_oop_disjoint_arraycopy_uninit  = generate_disjoint_int_oop_copy(false, true, &entry,
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3040
                                                                                     "oop_disjoint_arraycopy_uninit",
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3041
                                                                                     /*dest_uninitialized*/true);
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3042
      StubRoutines::_oop_arraycopy_uninit           = generate_conjoint_int_oop_copy(false, true, entry,
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3043
                                                                                     NULL, "oop_arraycopy_uninit",
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3044
                                                                                     /*dest_uninitialized*/true);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  3045
    } else {
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3046
      StubRoutines::_oop_disjoint_arraycopy  = generate_disjoint_long_oop_copy(false, true, &entry,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3047
                                                                               "oop_disjoint_arraycopy");
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3048
      StubRoutines::_oop_arraycopy           = generate_conjoint_long_oop_copy(false, true, entry,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3049
                                                                               &entry_oop_arraycopy, "oop_arraycopy");
8498
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3050
      StubRoutines::_oop_disjoint_arraycopy_uninit  = generate_disjoint_long_oop_copy(false, true, &entry,
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3051
                                                                                      "oop_disjoint_arraycopy_uninit",
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3052
                                                                                      /*dest_uninitialized*/true);
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3053
      StubRoutines::_oop_arraycopy_uninit           = generate_conjoint_long_oop_copy(false, true, entry,
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3054
                                                                                      NULL, "oop_arraycopy_uninit",
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3055
                                                                                      /*dest_uninitialized*/true);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 189
diff changeset
  3056
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3057
8498
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3058
    StubRoutines::_checkcast_arraycopy        = generate_checkcast_copy("checkcast_arraycopy", &entry_checkcast_arraycopy);
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3059
    StubRoutines::_checkcast_arraycopy_uninit = generate_checkcast_copy("checkcast_arraycopy_uninit", NULL,
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3060
                                                                        /*dest_uninitialized*/true);
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3061
8487
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3062
    StubRoutines::_unsafe_arraycopy    = generate_unsafe_copy("unsafe_arraycopy",
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3063
                                                              entry_jbyte_arraycopy,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3064
                                                              entry_jshort_arraycopy,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3065
                                                              entry_jint_arraycopy,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3066
                                                              entry_jlong_arraycopy);
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3067
    StubRoutines::_generic_arraycopy   = generate_generic_copy("generic_arraycopy",
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3068
                                                               entry_jbyte_arraycopy,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3069
                                                               entry_jshort_arraycopy,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3070
                                                               entry_jint_arraycopy,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3071
                                                               entry_oop_arraycopy,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3072
                                                               entry_jlong_arraycopy,
bf96596f06d2 7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents: 7431
diff changeset
  3073
                                                               entry_checkcast_arraycopy);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3074
6433
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  3075
    StubRoutines::_jbyte_fill = generate_fill(T_BYTE, false, "jbyte_fill");
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  3076
    StubRoutines::_jshort_fill = generate_fill(T_SHORT, false, "jshort_fill");
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  3077
    StubRoutines::_jint_fill = generate_fill(T_INT, false, "jint_fill");
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  3078
    StubRoutines::_arrayof_jbyte_fill = generate_fill(T_BYTE, true, "arrayof_jbyte_fill");
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  3079
    StubRoutines::_arrayof_jshort_fill = generate_fill(T_SHORT, true, "arrayof_jshort_fill");
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  3080
    StubRoutines::_arrayof_jint_fill = generate_fill(T_INT, true, "arrayof_jint_fill");
b0e4fafdc38b 4809552: Optimize Arrays.fill(...)
never
parents: 5706
diff changeset
  3081
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3082
    // We don't generate specialized code for HeapWord-aligned source
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3083
    // arrays, so just use the code we've already generated
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3084
    StubRoutines::_arrayof_jbyte_disjoint_arraycopy  = StubRoutines::_jbyte_disjoint_arraycopy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3085
    StubRoutines::_arrayof_jbyte_arraycopy           = StubRoutines::_jbyte_arraycopy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3086
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3087
    StubRoutines::_arrayof_jshort_disjoint_arraycopy = StubRoutines::_jshort_disjoint_arraycopy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3088
    StubRoutines::_arrayof_jshort_arraycopy          = StubRoutines::_jshort_arraycopy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3089
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3090
    StubRoutines::_arrayof_jint_disjoint_arraycopy   = StubRoutines::_jint_disjoint_arraycopy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3091
    StubRoutines::_arrayof_jint_arraycopy            = StubRoutines::_jint_arraycopy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3092
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3093
    StubRoutines::_arrayof_jlong_disjoint_arraycopy  = StubRoutines::_jlong_disjoint_arraycopy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3094
    StubRoutines::_arrayof_jlong_arraycopy           = StubRoutines::_jlong_arraycopy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3095
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3096
    StubRoutines::_arrayof_oop_disjoint_arraycopy    = StubRoutines::_oop_disjoint_arraycopy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3097
    StubRoutines::_arrayof_oop_arraycopy             = StubRoutines::_oop_arraycopy;
8498
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3098
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3099
    StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit    = StubRoutines::_oop_disjoint_arraycopy_uninit;
6398004126b9 6627983: G1: Bad oop deference during marking
iveresov
parents: 8487
diff changeset
  3100
    StubRoutines::_arrayof_oop_arraycopy_uninit             = StubRoutines::_oop_arraycopy_uninit;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3101
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3102
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3103
  // AES intrinsic stubs
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3104
  enum {AESBlockSize = 16};
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3105
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3106
  address generate_key_shuffle_mask() {
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3107
    __ align(16);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3108
    StubCodeMark mark(this, "StubRoutines", "key_shuffle_mask");
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3109
    address start = __ pc();
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3110
    __ emit_data64( 0x0405060700010203, relocInfo::none );
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3111
    __ emit_data64( 0x0c0d0e0f08090a0b, relocInfo::none );
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3112
    return start;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3113
  }
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3114
35154
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3115
  address generate_counter_shuffle_mask() {
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3116
    __ align(16);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3117
    StubCodeMark mark(this, "StubRoutines", "counter_shuffle_mask");
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3118
    address start = __ pc();
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3119
    __ emit_data64(0x08090a0b0c0d0e0f, relocInfo::none);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3120
    __ emit_data64(0x0001020304050607, relocInfo::none);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3121
    return start;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3122
  }
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3123
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3124
  // Utility routine for loading a 128-bit key word in little endian format
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3125
  // can optionally specify that the shuffle mask is already in an xmmregister
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3126
  void load_key(XMMRegister xmmdst, Register key, int offset, XMMRegister xmm_shuf_mask=NULL) {
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3127
    __ movdqu(xmmdst, Address(key, offset));
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3128
    if (xmm_shuf_mask != NULL) {
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3129
      __ pshufb(xmmdst, xmm_shuf_mask);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3130
    } else {
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3131
      __ pshufb(xmmdst, ExternalAddress(StubRoutines::x86::key_shuffle_mask_addr()));
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3132
    }
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3133
  }
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3134
35154
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3135
  // Utility routine for increase 128bit counter (iv in CTR mode)
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3136
  void inc_counter(Register reg, XMMRegister xmmdst, int inc_delta, Label& next_block) {
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3137
    __ pextrq(reg, xmmdst, 0x0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3138
    __ addq(reg, inc_delta);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3139
    __ pinsrq(xmmdst, reg, 0x0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3140
    __ jcc(Assembler::carryClear, next_block); // jump if no carry
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3141
    __ pextrq(reg, xmmdst, 0x01); // Carry
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3142
    __ addq(reg, 0x01);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3143
    __ pinsrq(xmmdst, reg, 0x01); //Carry end
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3144
    __ BIND(next_block);          // next instruction
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3145
  }
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3146
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3147
  // Arguments:
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3148
  //
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3149
  // Inputs:
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3150
  //   c_rarg0   - source byte array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3151
  //   c_rarg1   - destination byte array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3152
  //   c_rarg2   - K (key) in little endian int array
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3153
  //
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3154
  address generate_aescrypt_encryptBlock() {
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3155
    assert(UseAES, "need AES instructions and misaligned SSE support");
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3156
    __ align(CodeEntryAlignment);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3157
    StubCodeMark mark(this, "StubRoutines", "aescrypt_encryptBlock");
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3158
    Label L_doLast;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3159
    address start = __ pc();
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3160
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3161
    const Register from        = c_rarg0;  // source array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3162
    const Register to          = c_rarg1;  // destination array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3163
    const Register key         = c_rarg2;  // key array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3164
    const Register keylen      = rax;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3165
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3166
    const XMMRegister xmm_result = xmm0;
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3167
    const XMMRegister xmm_key_shuf_mask = xmm1;
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3168
    // On win64 xmm6-xmm15 must be preserved so don't use them.
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3169
    const XMMRegister xmm_temp1  = xmm2;
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3170
    const XMMRegister xmm_temp2  = xmm3;
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3171
    const XMMRegister xmm_temp3  = xmm4;
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3172
    const XMMRegister xmm_temp4  = xmm5;
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3173
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3174
    __ enter(); // required for proper stackwalking of RuntimeStub frame
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3175
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3176
    // keylen could be only {11, 13, 15} * 4 = {44, 52, 60}
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3177
    __ movl(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3178
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3179
    __ movdqu(xmm_key_shuf_mask, ExternalAddress(StubRoutines::x86::key_shuffle_mask_addr()));
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3180
    __ movdqu(xmm_result, Address(from, 0));  // get 16 bytes of input
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3181
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3182
    // For encryption, the java expanded key ordering is just what we need
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3183
    // we don't know if the key is aligned, hence not using load-execute form
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3184
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3185
    load_key(xmm_temp1, key, 0x00, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3186
    __ pxor(xmm_result, xmm_temp1);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3187
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3188
    load_key(xmm_temp1, key, 0x10, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3189
    load_key(xmm_temp2, key, 0x20, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3190
    load_key(xmm_temp3, key, 0x30, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3191
    load_key(xmm_temp4, key, 0x40, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3192
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3193
    __ aesenc(xmm_result, xmm_temp1);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3194
    __ aesenc(xmm_result, xmm_temp2);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3195
    __ aesenc(xmm_result, xmm_temp3);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3196
    __ aesenc(xmm_result, xmm_temp4);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3197
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3198
    load_key(xmm_temp1, key, 0x50, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3199
    load_key(xmm_temp2, key, 0x60, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3200
    load_key(xmm_temp3, key, 0x70, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3201
    load_key(xmm_temp4, key, 0x80, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3202
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3203
    __ aesenc(xmm_result, xmm_temp1);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3204
    __ aesenc(xmm_result, xmm_temp2);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3205
    __ aesenc(xmm_result, xmm_temp3);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3206
    __ aesenc(xmm_result, xmm_temp4);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3207
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3208
    load_key(xmm_temp1, key, 0x90, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3209
    load_key(xmm_temp2, key, 0xa0, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3210
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3211
    __ cmpl(keylen, 44);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3212
    __ jccb(Assembler::equal, L_doLast);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3213
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3214
    __ aesenc(xmm_result, xmm_temp1);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3215
    __ aesenc(xmm_result, xmm_temp2);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3216
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3217
    load_key(xmm_temp1, key, 0xb0, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3218
    load_key(xmm_temp2, key, 0xc0, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3219
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3220
    __ cmpl(keylen, 52);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3221
    __ jccb(Assembler::equal, L_doLast);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3222
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3223
    __ aesenc(xmm_result, xmm_temp1);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3224
    __ aesenc(xmm_result, xmm_temp2);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3225
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3226
    load_key(xmm_temp1, key, 0xd0, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3227
    load_key(xmm_temp2, key, 0xe0, xmm_key_shuf_mask);
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3228
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3229
    __ BIND(L_doLast);
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3230
    __ aesenc(xmm_result, xmm_temp1);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3231
    __ aesenclast(xmm_result, xmm_temp2);
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3232
    __ movdqu(Address(to, 0), xmm_result);        // store the result
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3233
    __ xorptr(rax, rax); // return 0
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3234
    __ leave(); // required for proper stackwalking of RuntimeStub frame
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3235
    __ ret(0);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3236
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3237
    return start;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3238
  }
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3239
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3240
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3241
  // Arguments:
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3242
  //
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3243
  // Inputs:
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3244
  //   c_rarg0   - source byte array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3245
  //   c_rarg1   - destination byte array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3246
  //   c_rarg2   - K (key) in little endian int array
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3247
  //
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3248
  address generate_aescrypt_decryptBlock() {
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3249
    assert(UseAES, "need AES instructions and misaligned SSE support");
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3250
    __ align(CodeEntryAlignment);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3251
    StubCodeMark mark(this, "StubRoutines", "aescrypt_decryptBlock");
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3252
    Label L_doLast;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3253
    address start = __ pc();
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3254
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3255
    const Register from        = c_rarg0;  // source array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3256
    const Register to          = c_rarg1;  // destination array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3257
    const Register key         = c_rarg2;  // key array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3258
    const Register keylen      = rax;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3259
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3260
    const XMMRegister xmm_result = xmm0;
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3261
    const XMMRegister xmm_key_shuf_mask = xmm1;
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3262
    // On win64 xmm6-xmm15 must be preserved so don't use them.
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3263
    const XMMRegister xmm_temp1  = xmm2;
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3264
    const XMMRegister xmm_temp2  = xmm3;
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3265
    const XMMRegister xmm_temp3  = xmm4;
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3266
    const XMMRegister xmm_temp4  = xmm5;
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3267
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3268
    __ enter(); // required for proper stackwalking of RuntimeStub frame
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3269
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3270
    // keylen could be only {11, 13, 15} * 4 = {44, 52, 60}
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3271
    __ movl(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3272
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3273
    __ movdqu(xmm_key_shuf_mask, ExternalAddress(StubRoutines::x86::key_shuffle_mask_addr()));
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3274
    __ movdqu(xmm_result, Address(from, 0));
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3275
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3276
    // for decryption java expanded key ordering is rotated one position from what we want
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3277
    // so we start from 0x10 here and hit 0x00 last
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3278
    // we don't know if the key is aligned, hence not using load-execute form
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3279
    load_key(xmm_temp1, key, 0x10, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3280
    load_key(xmm_temp2, key, 0x20, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3281
    load_key(xmm_temp3, key, 0x30, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3282
    load_key(xmm_temp4, key, 0x40, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3283
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3284
    __ pxor  (xmm_result, xmm_temp1);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3285
    __ aesdec(xmm_result, xmm_temp2);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3286
    __ aesdec(xmm_result, xmm_temp3);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3287
    __ aesdec(xmm_result, xmm_temp4);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3288
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3289
    load_key(xmm_temp1, key, 0x50, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3290
    load_key(xmm_temp2, key, 0x60, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3291
    load_key(xmm_temp3, key, 0x70, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3292
    load_key(xmm_temp4, key, 0x80, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3293
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3294
    __ aesdec(xmm_result, xmm_temp1);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3295
    __ aesdec(xmm_result, xmm_temp2);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3296
    __ aesdec(xmm_result, xmm_temp3);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3297
    __ aesdec(xmm_result, xmm_temp4);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3298
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3299
    load_key(xmm_temp1, key, 0x90, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3300
    load_key(xmm_temp2, key, 0xa0, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3301
    load_key(xmm_temp3, key, 0x00, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3302
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3303
    __ cmpl(keylen, 44);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3304
    __ jccb(Assembler::equal, L_doLast);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3305
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3306
    __ aesdec(xmm_result, xmm_temp1);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3307
    __ aesdec(xmm_result, xmm_temp2);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3308
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3309
    load_key(xmm_temp1, key, 0xb0, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3310
    load_key(xmm_temp2, key, 0xc0, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3311
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3312
    __ cmpl(keylen, 52);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3313
    __ jccb(Assembler::equal, L_doLast);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3314
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3315
    __ aesdec(xmm_result, xmm_temp1);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3316
    __ aesdec(xmm_result, xmm_temp2);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3317
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3318
    load_key(xmm_temp1, key, 0xd0, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3319
    load_key(xmm_temp2, key, 0xe0, xmm_key_shuf_mask);
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3320
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3321
    __ BIND(L_doLast);
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3322
    __ aesdec(xmm_result, xmm_temp1);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3323
    __ aesdec(xmm_result, xmm_temp2);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3324
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3325
    // for decryption the aesdeclast operation is always on key+0x00
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3326
    __ aesdeclast(xmm_result, xmm_temp3);
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3327
    __ movdqu(Address(to, 0), xmm_result);  // store the result
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3328
    __ xorptr(rax, rax); // return 0
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3329
    __ leave(); // required for proper stackwalking of RuntimeStub frame
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3330
    __ ret(0);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3331
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3332
    return start;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3333
  }
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3334
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3335
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3336
  // Arguments:
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3337
  //
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3338
  // Inputs:
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3339
  //   c_rarg0   - source byte array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3340
  //   c_rarg1   - destination byte array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3341
  //   c_rarg2   - K (key) in little endian int array
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3342
  //   c_rarg3   - r vector byte array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3343
  //   c_rarg4   - input length
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3344
  //
22505
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3345
  // Output:
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3346
  //   rax       - input length
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3347
  //
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3348
  address generate_cipherBlockChaining_encryptAESCrypt() {
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3349
    assert(UseAES, "need AES instructions and misaligned SSE support");
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3350
    __ align(CodeEntryAlignment);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3351
    StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_encryptAESCrypt");
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3352
    address start = __ pc();
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3353
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3354
    Label L_exit, L_key_192_256, L_key_256, L_loopTop_128, L_loopTop_192, L_loopTop_256;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3355
    const Register from        = c_rarg0;  // source array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3356
    const Register to          = c_rarg1;  // destination array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3357
    const Register key         = c_rarg2;  // key array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3358
    const Register rvec        = c_rarg3;  // r byte array initialized from initvector array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3359
                                           // and left with the results of the last encryption block
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3360
#ifndef _WIN64
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3361
    const Register len_reg     = c_rarg4;  // src len (must be multiple of blocksize 16)
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3362
#else
22505
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3363
    const Address  len_mem(rbp, 6 * wordSize);  // length is on stack on Win64
43423
bcaab17f72a5 8171974: Fix for R10 Register clobbering with usage of ExternalAddress
vdeshpande
parents: 42618
diff changeset
  3364
    const Register len_reg     = r11;      // pick the volatile windows register
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3365
#endif
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3366
    const Register pos         = rax;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3367
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3368
    // xmm register assignments for the loops below
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3369
    const XMMRegister xmm_result = xmm0;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3370
    const XMMRegister xmm_temp   = xmm1;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3371
    // keys 0-10 preloaded into xmm2-xmm12
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3372
    const int XMM_REG_NUM_KEY_FIRST = 2;
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3373
    const int XMM_REG_NUM_KEY_LAST  = 15;
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3374
    const XMMRegister xmm_key0   = as_XMMRegister(XMM_REG_NUM_KEY_FIRST);
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3375
    const XMMRegister xmm_key10  = as_XMMRegister(XMM_REG_NUM_KEY_FIRST+10);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3376
    const XMMRegister xmm_key11  = as_XMMRegister(XMM_REG_NUM_KEY_FIRST+11);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3377
    const XMMRegister xmm_key12  = as_XMMRegister(XMM_REG_NUM_KEY_FIRST+12);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3378
    const XMMRegister xmm_key13  = as_XMMRegister(XMM_REG_NUM_KEY_FIRST+13);
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3379
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3380
    __ enter(); // required for proper stackwalking of RuntimeStub frame
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3381
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3382
#ifdef _WIN64
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3383
    // on win64, fill len_reg from stack position
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3384
    __ movl(len_reg, len_mem);
22505
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3385
#else
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3386
    __ push(len_reg); // Save
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3387
#endif
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3388
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3389
    const XMMRegister xmm_key_shuf_mask = xmm_temp;  // used temporarily to swap key bytes up front
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3390
    __ movdqu(xmm_key_shuf_mask, ExternalAddress(StubRoutines::x86::key_shuffle_mask_addr()));
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3391
    // load up xmm regs xmm2 thru xmm12 with key 0x00 - 0xa0
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3392
    for (int rnum = XMM_REG_NUM_KEY_FIRST, offset = 0x00; rnum <= XMM_REG_NUM_KEY_FIRST+10; rnum++) {
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3393
      load_key(as_XMMRegister(rnum), key, offset, xmm_key_shuf_mask);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3394
      offset += 0x10;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3395
    }
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3396
    __ movdqu(xmm_result, Address(rvec, 0x00));   // initialize xmm_result with r vec
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3397
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3398
    // now split to different paths depending on the keylen (len in ints of AESCrypt.KLE array (52=192, or 60=256))
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3399
    __ movl(rax, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3400
    __ cmpl(rax, 44);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3401
    __ jcc(Assembler::notEqual, L_key_192_256);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3402
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3403
    // 128 bit code follows here
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3404
    __ movptr(pos, 0);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3405
    __ align(OptoLoopAlignment);
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3406
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3407
    __ BIND(L_loopTop_128);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3408
    __ movdqu(xmm_temp, Address(from, pos, Address::times_1, 0));   // get next 16 bytes of input
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3409
    __ pxor  (xmm_result, xmm_temp);               // xor with the current r vector
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3410
    __ pxor  (xmm_result, xmm_key0);               // do the aes rounds
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3411
    for (int rnum = XMM_REG_NUM_KEY_FIRST + 1; rnum <= XMM_REG_NUM_KEY_FIRST + 9; rnum++) {
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3412
      __ aesenc(xmm_result, as_XMMRegister(rnum));
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3413
    }
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3414
    __ aesenclast(xmm_result, xmm_key10);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3415
    __ movdqu(Address(to, pos, Address::times_1, 0), xmm_result);     // store into the next 16 bytes of output
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3416
    // no need to store r to memory until we exit
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3417
    __ addptr(pos, AESBlockSize);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3418
    __ subptr(len_reg, AESBlockSize);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3419
    __ jcc(Assembler::notEqual, L_loopTop_128);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3420
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3421
    __ BIND(L_exit);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3422
    __ movdqu(Address(rvec, 0), xmm_result);     // final value of r stored in rvec of CipherBlockChaining object
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3423
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3424
#ifdef _WIN64
22505
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3425
    __ movl(rax, len_mem);
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3426
#else
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3427
    __ pop(rax); // return length
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3428
#endif
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3429
    __ leave(); // required for proper stackwalking of RuntimeStub frame
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3430
    __ ret(0);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3431
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3432
    __ BIND(L_key_192_256);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3433
    // here rax = len in ints of AESCrypt.KLE array (52=192, or 60=256)
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3434
    load_key(xmm_key11, key, 0xb0, xmm_key_shuf_mask);
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3435
    load_key(xmm_key12, key, 0xc0, xmm_key_shuf_mask);
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3436
    __ cmpl(rax, 52);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3437
    __ jcc(Assembler::notEqual, L_key_256);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3438
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3439
    // 192-bit code follows here (could be changed to use more xmm registers)
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3440
    __ movptr(pos, 0);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3441
    __ align(OptoLoopAlignment);
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3442
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3443
    __ BIND(L_loopTop_192);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3444
    __ movdqu(xmm_temp, Address(from, pos, Address::times_1, 0));   // get next 16 bytes of input
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3445
    __ pxor  (xmm_result, xmm_temp);               // xor with the current r vector
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3446
    __ pxor  (xmm_result, xmm_key0);               // do the aes rounds
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3447
    for (int rnum = XMM_REG_NUM_KEY_FIRST + 1; rnum  <= XMM_REG_NUM_KEY_FIRST + 11; rnum++) {
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3448
      __ aesenc(xmm_result, as_XMMRegister(rnum));
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3449
    }
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3450
    __ aesenclast(xmm_result, xmm_key12);
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3451
    __ movdqu(Address(to, pos, Address::times_1, 0), xmm_result);     // store into the next 16 bytes of output
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3452
    // no need to store r to memory until we exit
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3453
    __ addptr(pos, AESBlockSize);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3454
    __ subptr(len_reg, AESBlockSize);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3455
    __ jcc(Assembler::notEqual, L_loopTop_192);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3456
    __ jmp(L_exit);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3457
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3458
    __ BIND(L_key_256);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3459
    // 256-bit code follows here (could be changed to use more xmm registers)
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3460
    load_key(xmm_key13, key, 0xd0, xmm_key_shuf_mask);
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3461
    __ movptr(pos, 0);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3462
    __ align(OptoLoopAlignment);
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3463
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3464
    __ BIND(L_loopTop_256);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3465
    __ movdqu(xmm_temp, Address(from, pos, Address::times_1, 0));   // get next 16 bytes of input
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3466
    __ pxor  (xmm_result, xmm_temp);               // xor with the current r vector
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3467
    __ pxor  (xmm_result, xmm_key0);               // do the aes rounds
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3468
    for (int rnum = XMM_REG_NUM_KEY_FIRST + 1; rnum  <= XMM_REG_NUM_KEY_FIRST + 13; rnum++) {
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3469
      __ aesenc(xmm_result, as_XMMRegister(rnum));
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3470
    }
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3471
    load_key(xmm_temp, key, 0xe0);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3472
    __ aesenclast(xmm_result, xmm_temp);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3473
    __ movdqu(Address(to, pos, Address::times_1, 0), xmm_result);     // store into the next 16 bytes of output
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3474
    // no need to store r to memory until we exit
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3475
    __ addptr(pos, AESBlockSize);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3476
    __ subptr(len_reg, AESBlockSize);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3477
    __ jcc(Assembler::notEqual, L_loopTop_256);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3478
    __ jmp(L_exit);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3479
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3480
    return start;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3481
  }
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3482
18740
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3483
  // Safefetch stubs.
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3484
  void generate_safefetch(const char* name, int size, address* entry,
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3485
                          address* fault_pc, address* continuation_pc) {
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3486
    // safefetch signatures:
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3487
    //   int      SafeFetch32(int*      adr, int      errValue);
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3488
    //   intptr_t SafeFetchN (intptr_t* adr, intptr_t errValue);
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3489
    //
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3490
    // arguments:
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3491
    //   c_rarg0 = adr
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3492
    //   c_rarg1 = errValue
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3493
    //
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3494
    // result:
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3495
    //   PPC_RET  = *adr or errValue
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3496
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3497
    StubCodeMark mark(this, "StubRoutines", name);
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3498
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3499
    // Entry point, pc or function descriptor.
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3500
    *entry = __ pc();
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3501
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3502
    // Load *adr into c_rarg1, may fault.
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3503
    *fault_pc = __ pc();
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3504
    switch (size) {
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3505
      case 4:
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3506
        // int32_t
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3507
        __ movl(c_rarg1, Address(c_rarg0, 0));
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3508
        break;
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3509
      case 8:
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3510
        // int64_t
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3511
        __ movq(c_rarg1, Address(c_rarg0, 0));
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3512
        break;
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3513
      default:
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3514
        ShouldNotReachHere();
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3515
    }
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3516
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3517
    // return errValue or *adr
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3518
    *continuation_pc = __ pc();
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3519
    __ movq(rax, c_rarg1);
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3520
    __ ret(0);
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  3521
  }
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3522
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3523
  // This is a version of CBC/AES Decrypt which does 4 blocks in a loop at a time
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3524
  // to hide instruction latency
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3525
  //
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3526
  // Arguments:
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3527
  //
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3528
  // Inputs:
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3529
  //   c_rarg0   - source byte array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3530
  //   c_rarg1   - destination byte array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3531
  //   c_rarg2   - K (key) in little endian int array
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3532
  //   c_rarg3   - r vector byte array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3533
  //   c_rarg4   - input length
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3534
  //
22505
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3535
  // Output:
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3536
  //   rax       - input length
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3537
  //
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3538
  address generate_cipherBlockChaining_decryptAESCrypt_Parallel() {
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3539
    assert(UseAES, "need AES instructions and misaligned SSE support");
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3540
    __ align(CodeEntryAlignment);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3541
    StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_decryptAESCrypt");
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3542
    address start = __ pc();
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3543
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3544
    const Register from        = c_rarg0;  // source array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3545
    const Register to          = c_rarg1;  // destination array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3546
    const Register key         = c_rarg2;  // key array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3547
    const Register rvec        = c_rarg3;  // r byte array initialized from initvector array address
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3548
                                           // and left with the results of the last encryption block
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3549
#ifndef _WIN64
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3550
    const Register len_reg     = c_rarg4;  // src len (must be multiple of blocksize 16)
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3551
#else
22505
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3552
    const Address  len_mem(rbp, 6 * wordSize);  // length is on stack on Win64
43423
bcaab17f72a5 8171974: Fix for R10 Register clobbering with usage of ExternalAddress
vdeshpande
parents: 42618
diff changeset
  3553
    const Register len_reg     = r11;      // pick the volatile windows register
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3554
#endif
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3555
    const Register pos         = rax;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3556
36825
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3557
    const int PARALLEL_FACTOR = 4;
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3558
    const int ROUNDS[3] = { 10, 12, 14 }; // aes rounds for key128, key192, key256
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3559
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3560
    Label L_exit;
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3561
    Label L_singleBlock_loopTopHead[3]; // 128, 192, 256
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3562
    Label L_singleBlock_loopTopHead2[3]; // 128, 192, 256
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3563
    Label L_singleBlock_loopTop[3]; // 128, 192, 256
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3564
    Label L_multiBlock_loopTopHead[3]; // 128, 192, 256
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3565
    Label L_multiBlock_loopTop[3]; // 128, 192, 256
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3566
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3567
    // keys 0-10 preloaded into xmm5-xmm15
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3568
    const int XMM_REG_NUM_KEY_FIRST = 5;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3569
    const int XMM_REG_NUM_KEY_LAST  = 15;
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3570
    const XMMRegister xmm_key_first = as_XMMRegister(XMM_REG_NUM_KEY_FIRST);
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3571
    const XMMRegister xmm_key_last  = as_XMMRegister(XMM_REG_NUM_KEY_LAST);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3572
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3573
    __ enter(); // required for proper stackwalking of RuntimeStub frame
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3574
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3575
#ifdef _WIN64
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3576
    // on win64, fill len_reg from stack position
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3577
    __ movl(len_reg, len_mem);
22505
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3578
#else
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3579
    __ push(len_reg); // Save
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3580
#endif
36825
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3581
    __ push(rbx);
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3582
    // the java expanded key ordering is rotated one position from what we want
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3583
    // so we start from 0x10 here and hit 0x00 last
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3584
    const XMMRegister xmm_key_shuf_mask = xmm1;  // used temporarily to swap key bytes up front
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3585
    __ movdqu(xmm_key_shuf_mask, ExternalAddress(StubRoutines::x86::key_shuffle_mask_addr()));
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3586
    // load up xmm regs 5 thru 15 with key 0x10 - 0xa0 - 0x00
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3587
    for (int rnum = XMM_REG_NUM_KEY_FIRST, offset = 0x10; rnum < XMM_REG_NUM_KEY_LAST; rnum++) {
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3588
      load_key(as_XMMRegister(rnum), key, offset, xmm_key_shuf_mask);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3589
      offset += 0x10;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3590
    }
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3591
    load_key(xmm_key_last, key, 0x00, xmm_key_shuf_mask);
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3592
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3593
    const XMMRegister xmm_prev_block_cipher = xmm1;  // holds cipher of previous block
14834
f29c91f2f22b 8004835: Improve AES intrinsics on x86
kvn
parents: 14633
diff changeset
  3594
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3595
    // registers holding the four results in the parallelized loop
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3596
    const XMMRegister xmm_result0 = xmm0;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3597
    const XMMRegister xmm_result1 = xmm2;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3598
    const XMMRegister xmm_result2 = xmm3;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3599
    const XMMRegister xmm_result3 = xmm4;
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3600
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3601
    __ movdqu(xmm_prev_block_cipher, Address(rvec, 0x00));   // initialize with initial rvec
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3602
36825
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3603
    __ xorptr(pos, pos);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3604
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3605
    // now split to different paths depending on the keylen (len in ints of AESCrypt.KLE array (52=192, or 60=256))
36825
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3606
    __ movl(rbx, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3607
    __ cmpl(rbx, 52);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3608
    __ jcc(Assembler::equal, L_multiBlock_loopTopHead[1]);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3609
    __ cmpl(rbx, 60);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3610
    __ jcc(Assembler::equal, L_multiBlock_loopTopHead[2]);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3611
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3612
#define DoFour(opc, src_reg)           \
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3613
  __ opc(xmm_result0, src_reg);         \
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3614
  __ opc(xmm_result1, src_reg);         \
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3615
  __ opc(xmm_result2, src_reg);         \
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3616
  __ opc(xmm_result3, src_reg);         \
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3617
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3618
    for (int k = 0; k < 3; ++k) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3619
      __ BIND(L_multiBlock_loopTopHead[k]);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3620
      if (k != 0) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3621
        __ cmpptr(len_reg, PARALLEL_FACTOR * AESBlockSize); // see if at least 4 blocks left
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3622
        __ jcc(Assembler::less, L_singleBlock_loopTopHead2[k]);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3623
      }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3624
      if (k == 1) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3625
        __ subptr(rsp, 6 * wordSize);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3626
        __ movdqu(Address(rsp, 0), xmm15); //save last_key from xmm15
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3627
        load_key(xmm15, key, 0xb0); // 0xb0; 192-bit key goes up to 0xc0
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3628
        __ movdqu(Address(rsp, 2 * wordSize), xmm15);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3629
        load_key(xmm1, key, 0xc0);  // 0xc0;
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3630
        __ movdqu(Address(rsp, 4 * wordSize), xmm1);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3631
      } else if (k == 2) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3632
        __ subptr(rsp, 10 * wordSize);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3633
        __ movdqu(Address(rsp, 0), xmm15); //save last_key from xmm15
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3634
        load_key(xmm15, key, 0xd0); // 0xd0; 256-bit key goes upto 0xe0
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3635
        __ movdqu(Address(rsp, 6 * wordSize), xmm15);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3636
        load_key(xmm1, key, 0xe0);  // 0xe0;
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3637
        __ movdqu(Address(rsp, 8 * wordSize), xmm1);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3638
        load_key(xmm15, key, 0xb0); // 0xb0;
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3639
        __ movdqu(Address(rsp, 2 * wordSize), xmm15);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3640
        load_key(xmm1, key, 0xc0);  // 0xc0;
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3641
        __ movdqu(Address(rsp, 4 * wordSize), xmm1);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3642
      }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3643
      __ align(OptoLoopAlignment);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3644
      __ BIND(L_multiBlock_loopTop[k]);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3645
      __ cmpptr(len_reg, PARALLEL_FACTOR * AESBlockSize); // see if at least 4 blocks left
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3646
      __ jcc(Assembler::less, L_singleBlock_loopTopHead[k]);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3647
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3648
      if  (k != 0) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3649
        __ movdqu(xmm15, Address(rsp, 2 * wordSize));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3650
        __ movdqu(xmm1, Address(rsp, 4 * wordSize));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3651
      }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3652
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3653
      __ movdqu(xmm_result0, Address(from, pos, Address::times_1, 0 * AESBlockSize)); // get next 4 blocks into xmmresult registers
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3654
      __ movdqu(xmm_result1, Address(from, pos, Address::times_1, 1 * AESBlockSize));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3655
      __ movdqu(xmm_result2, Address(from, pos, Address::times_1, 2 * AESBlockSize));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3656
      __ movdqu(xmm_result3, Address(from, pos, Address::times_1, 3 * AESBlockSize));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3657
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3658
      DoFour(pxor, xmm_key_first);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3659
      if (k == 0) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3660
        for (int rnum = 1; rnum < ROUNDS[k]; rnum++) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3661
          DoFour(aesdec, as_XMMRegister(rnum + XMM_REG_NUM_KEY_FIRST));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3662
        }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3663
        DoFour(aesdeclast, xmm_key_last);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3664
      } else if (k == 1) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3665
        for (int rnum = 1; rnum <= ROUNDS[k]-2; rnum++) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3666
          DoFour(aesdec, as_XMMRegister(rnum + XMM_REG_NUM_KEY_FIRST));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3667
        }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3668
        __ movdqu(xmm_key_last, Address(rsp, 0)); // xmm15 needs to be loaded again.
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3669
        DoFour(aesdec, xmm1);  // key : 0xc0
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3670
        __ movdqu(xmm_prev_block_cipher, Address(rvec, 0x00));  // xmm1 needs to be loaded again
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3671
        DoFour(aesdeclast, xmm_key_last);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3672
      } else if (k == 2) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3673
        for (int rnum = 1; rnum <= ROUNDS[k] - 4; rnum++) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3674
          DoFour(aesdec, as_XMMRegister(rnum + XMM_REG_NUM_KEY_FIRST));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3675
        }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3676
        DoFour(aesdec, xmm1);  // key : 0xc0
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3677
        __ movdqu(xmm15, Address(rsp, 6 * wordSize));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3678
        __ movdqu(xmm1, Address(rsp, 8 * wordSize));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3679
        DoFour(aesdec, xmm15);  // key : 0xd0
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3680
        __ movdqu(xmm_key_last, Address(rsp, 0)); // xmm15 needs to be loaded again.
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3681
        DoFour(aesdec, xmm1);  // key : 0xe0
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3682
        __ movdqu(xmm_prev_block_cipher, Address(rvec, 0x00));  // xmm1 needs to be loaded again
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3683
        DoFour(aesdeclast, xmm_key_last);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3684
      }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3685
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3686
      // for each result, xor with the r vector of previous cipher block
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3687
      __ pxor(xmm_result0, xmm_prev_block_cipher);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3688
      __ movdqu(xmm_prev_block_cipher, Address(from, pos, Address::times_1, 0 * AESBlockSize));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3689
      __ pxor(xmm_result1, xmm_prev_block_cipher);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3690
      __ movdqu(xmm_prev_block_cipher, Address(from, pos, Address::times_1, 1 * AESBlockSize));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3691
      __ pxor(xmm_result2, xmm_prev_block_cipher);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3692
      __ movdqu(xmm_prev_block_cipher, Address(from, pos, Address::times_1, 2 * AESBlockSize));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3693
      __ pxor(xmm_result3, xmm_prev_block_cipher);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3694
      __ movdqu(xmm_prev_block_cipher, Address(from, pos, Address::times_1, 3 * AESBlockSize));   // this will carry over to next set of blocks
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3695
      if (k != 0) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3696
        __ movdqu(Address(rvec, 0x00), xmm_prev_block_cipher);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3697
      }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3698
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3699
      __ movdqu(Address(to, pos, Address::times_1, 0 * AESBlockSize), xmm_result0);     // store 4 results into the next 64 bytes of output
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3700
      __ movdqu(Address(to, pos, Address::times_1, 1 * AESBlockSize), xmm_result1);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3701
      __ movdqu(Address(to, pos, Address::times_1, 2 * AESBlockSize), xmm_result2);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3702
      __ movdqu(Address(to, pos, Address::times_1, 3 * AESBlockSize), xmm_result3);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3703
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3704
      __ addptr(pos, PARALLEL_FACTOR * AESBlockSize);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3705
      __ subptr(len_reg, PARALLEL_FACTOR * AESBlockSize);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3706
      __ jmp(L_multiBlock_loopTop[k]);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3707
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3708
      // registers used in the non-parallelized loops
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3709
      // xmm register assignments for the loops below
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3710
      const XMMRegister xmm_result = xmm0;
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3711
      const XMMRegister xmm_prev_block_cipher_save = xmm2;
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3712
      const XMMRegister xmm_key11 = xmm3;
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3713
      const XMMRegister xmm_key12 = xmm4;
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3714
      const XMMRegister key_tmp = xmm4;
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3715
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3716
      __ BIND(L_singleBlock_loopTopHead[k]);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3717
      if (k == 1) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3718
        __ addptr(rsp, 6 * wordSize);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3719
      } else if (k == 2) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3720
        __ addptr(rsp, 10 * wordSize);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3721
      }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3722
      __ cmpptr(len_reg, 0); // any blocks left??
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3723
      __ jcc(Assembler::equal, L_exit);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3724
      __ BIND(L_singleBlock_loopTopHead2[k]);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3725
      if (k == 1) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3726
        load_key(xmm_key11, key, 0xb0); // 0xb0; 192-bit key goes upto 0xc0
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3727
        load_key(xmm_key12, key, 0xc0); // 0xc0; 192-bit key goes upto 0xc0
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3728
      }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3729
      if (k == 2) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3730
        load_key(xmm_key11, key, 0xb0); // 0xb0; 256-bit key goes upto 0xe0
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3731
      }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3732
      __ align(OptoLoopAlignment);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3733
      __ BIND(L_singleBlock_loopTop[k]);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3734
      __ movdqu(xmm_result, Address(from, pos, Address::times_1, 0)); // get next 16 bytes of cipher input
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3735
      __ movdqa(xmm_prev_block_cipher_save, xmm_result); // save for next r vector
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3736
      __ pxor(xmm_result, xmm_key_first); // do the aes dec rounds
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3737
      for (int rnum = 1; rnum <= 9 ; rnum++) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3738
          __ aesdec(xmm_result, as_XMMRegister(rnum + XMM_REG_NUM_KEY_FIRST));
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3739
      }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3740
      if (k == 1) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3741
        __ aesdec(xmm_result, xmm_key11);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3742
        __ aesdec(xmm_result, xmm_key12);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3743
      }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3744
      if (k == 2) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3745
        __ aesdec(xmm_result, xmm_key11);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3746
        load_key(key_tmp, key, 0xc0);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3747
        __ aesdec(xmm_result, key_tmp);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3748
        load_key(key_tmp, key, 0xd0);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3749
        __ aesdec(xmm_result, key_tmp);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3750
        load_key(key_tmp, key, 0xe0);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3751
        __ aesdec(xmm_result, key_tmp);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3752
      }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3753
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3754
      __ aesdeclast(xmm_result, xmm_key_last); // xmm15 always came from key+0
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3755
      __ pxor(xmm_result, xmm_prev_block_cipher); // xor with the current r vector
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3756
      __ movdqu(Address(to, pos, Address::times_1, 0), xmm_result); // store into the next 16 bytes of output
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3757
      // no need to store r to memory until we exit
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3758
      __ movdqa(xmm_prev_block_cipher, xmm_prev_block_cipher_save); // set up next r vector with cipher input from this block
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3759
      __ addptr(pos, AESBlockSize);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3760
      __ subptr(len_reg, AESBlockSize);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3761
      __ jcc(Assembler::notEqual, L_singleBlock_loopTop[k]);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3762
      if (k != 2) {
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3763
        __ jmp(L_exit);
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3764
      }
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3765
    } //for 128/192/256
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3766
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3767
    __ BIND(L_exit);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3768
    __ movdqu(Address(rvec, 0), xmm_prev_block_cipher);     // final value of r stored in rvec of CipherBlockChaining object
36825
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3769
    __ pop(rbx);
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3770
#ifdef _WIN64
22505
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3771
    __ movl(rax, len_mem);
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3772
#else
4523090c9674 8002074: Support for AES on SPARC
kvn
parents: 19319
diff changeset
  3773
    __ pop(rax); // return length
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3774
#endif
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3775
    __ leave(); // required for proper stackwalking of RuntimeStub frame
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3776
    __ ret(0);
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3777
    return start;
36825
6ebe5519b753 8152354: Update for x86 AES CBC Decryption
vdeshpande
parents: 36561
diff changeset
  3778
}
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  3779
57786
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3780
  address generate_electronicCodeBook_encryptAESCrypt() {
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3781
    __ align(CodeEntryAlignment);
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3782
    StubCodeMark mark(this, "StubRoutines", "electronicCodeBook_encryptAESCrypt");
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3783
    address start = __ pc();
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3784
    const Register from = c_rarg0;  // source array address
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3785
    const Register to = c_rarg1;  // destination array address
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3786
    const Register key = c_rarg2;  // key array address
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3787
    const Register len = c_rarg3;  // src len (must be multiple of blocksize 16)
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3788
    __ enter(); // required for proper stackwalking of RuntimeStub frame
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3789
    __ aesecb_encrypt(from, to, key, len);
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3790
    __ leave(); // required for proper stackwalking of RuntimeStub frame
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3791
    __ ret(0);
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3792
    return start;
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3793
 }
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3794
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3795
  address generate_electronicCodeBook_decryptAESCrypt() {
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3796
    __ align(CodeEntryAlignment);
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3797
    StubCodeMark mark(this, "StubRoutines", "electronicCodeBook_decryptAESCrypt");
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3798
    address start = __ pc();
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3799
    const Register from = c_rarg0;  // source array address
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3800
    const Register to = c_rarg1;  // destination array address
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3801
    const Register key = c_rarg2;  // key array address
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3802
    const Register len = c_rarg3;  // src len (must be multiple of blocksize 16)
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3803
    __ enter(); // required for proper stackwalking of RuntimeStub frame
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3804
    __ aesecb_decrypt(from, to, key, len);
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3805
    __ leave(); // required for proper stackwalking of RuntimeStub frame
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3806
    __ ret(0);
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3807
    return start;
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3808
  }
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  3809
36555
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3810
  address generate_upper_word_mask() {
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3811
    __ align(64);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3812
    StubCodeMark mark(this, "StubRoutines", "upper_word_mask");
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3813
    address start = __ pc();
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3814
    __ emit_data64(0x0000000000000000, relocInfo::none);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3815
    __ emit_data64(0xFFFFFFFF00000000, relocInfo::none);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3816
    return start;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3817
  }
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3818
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3819
  address generate_shuffle_byte_flip_mask() {
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3820
    __ align(64);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3821
    StubCodeMark mark(this, "StubRoutines", "shuffle_byte_flip_mask");
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3822
    address start = __ pc();
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3823
    __ emit_data64(0x08090a0b0c0d0e0f, relocInfo::none);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3824
    __ emit_data64(0x0001020304050607, relocInfo::none);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3825
    return start;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3826
  }
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3827
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3828
  // ofs and limit are use for multi-block byte array.
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3829
  // int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit)
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3830
  address generate_sha1_implCompress(bool multi_block, const char *name) {
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3831
    __ align(CodeEntryAlignment);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3832
    StubCodeMark mark(this, "StubRoutines", name);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3833
    address start = __ pc();
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3834
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3835
    Register buf = c_rarg0;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3836
    Register state = c_rarg1;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3837
    Register ofs = c_rarg2;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3838
    Register limit = c_rarg3;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3839
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3840
    const XMMRegister abcd = xmm0;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3841
    const XMMRegister e0 = xmm1;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3842
    const XMMRegister e1 = xmm2;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3843
    const XMMRegister msg0 = xmm3;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3844
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3845
    const XMMRegister msg1 = xmm4;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3846
    const XMMRegister msg2 = xmm5;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3847
    const XMMRegister msg3 = xmm6;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3848
    const XMMRegister shuf_mask = xmm7;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3849
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3850
    __ enter();
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3851
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3852
    __ subptr(rsp, 4 * wordSize);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3853
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3854
    __ fast_sha1(abcd, e0, e1, msg0, msg1, msg2, msg3, shuf_mask,
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3855
      buf, state, ofs, limit, rsp, multi_block);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3856
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3857
    __ addptr(rsp, 4 * wordSize);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3858
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3859
    __ leave();
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3860
    __ ret(0);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3861
    return start;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3862
  }
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3863
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3864
  address generate_pshuffle_byte_flip_mask() {
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3865
    __ align(64);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3866
    StubCodeMark mark(this, "StubRoutines", "pshuffle_byte_flip_mask");
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3867
    address start = __ pc();
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3868
    __ emit_data64(0x0405060700010203, relocInfo::none);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3869
    __ emit_data64(0x0c0d0e0f08090a0b, relocInfo::none);
38135
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3870
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3871
    if (VM_Version::supports_avx2()) {
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3872
      __ emit_data64(0x0405060700010203, relocInfo::none); // second copy
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3873
      __ emit_data64(0x0c0d0e0f08090a0b, relocInfo::none);
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3874
      // _SHUF_00BA
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3875
      __ emit_data64(0x0b0a090803020100, relocInfo::none);
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3876
      __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none);
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3877
      __ emit_data64(0x0b0a090803020100, relocInfo::none);
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3878
      __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none);
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3879
      // _SHUF_DC00
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3880
      __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none);
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3881
      __ emit_data64(0x0b0a090803020100, relocInfo::none);
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3882
      __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none);
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3883
      __ emit_data64(0x0b0a090803020100, relocInfo::none);
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3884
    }
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3885
36555
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3886
    return start;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3887
  }
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3888
42039
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3889
  //Mask for byte-swapping a couple of qwords in an XMM register using (v)pshufb.
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3890
  address generate_pshuffle_byte_flip_mask_sha512() {
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3891
    __ align(32);
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3892
    StubCodeMark mark(this, "StubRoutines", "pshuffle_byte_flip_mask_sha512");
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3893
    address start = __ pc();
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3894
    if (VM_Version::supports_avx2()) {
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3895
      __ emit_data64(0x0001020304050607, relocInfo::none); // PSHUFFLE_BYTE_FLIP_MASK
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3896
      __ emit_data64(0x08090a0b0c0d0e0f, relocInfo::none);
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3897
      __ emit_data64(0x1011121314151617, relocInfo::none);
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3898
      __ emit_data64(0x18191a1b1c1d1e1f, relocInfo::none);
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3899
      __ emit_data64(0x0000000000000000, relocInfo::none); //MASK_YMM_LO
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3900
      __ emit_data64(0x0000000000000000, relocInfo::none);
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3901
      __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none);
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3902
      __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none);
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3903
    }
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3904
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3905
    return start;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3906
  }
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3907
36555
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3908
// ofs and limit are use for multi-block byte array.
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3909
// int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit)
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3910
  address generate_sha256_implCompress(bool multi_block, const char *name) {
38135
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3911
    assert(VM_Version::supports_sha() || VM_Version::supports_avx2(), "");
36555
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3912
    __ align(CodeEntryAlignment);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3913
    StubCodeMark mark(this, "StubRoutines", name);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3914
    address start = __ pc();
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3915
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3916
    Register buf = c_rarg0;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3917
    Register state = c_rarg1;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3918
    Register ofs = c_rarg2;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3919
    Register limit = c_rarg3;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3920
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3921
    const XMMRegister msg = xmm0;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3922
    const XMMRegister state0 = xmm1;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3923
    const XMMRegister state1 = xmm2;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3924
    const XMMRegister msgtmp0 = xmm3;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3925
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3926
    const XMMRegister msgtmp1 = xmm4;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3927
    const XMMRegister msgtmp2 = xmm5;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3928
    const XMMRegister msgtmp3 = xmm6;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3929
    const XMMRegister msgtmp4 = xmm7;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3930
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3931
    const XMMRegister shuf_mask = xmm8;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3932
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3933
    __ enter();
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3934
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3935
    __ subptr(rsp, 4 * wordSize);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3936
38135
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3937
    if (VM_Version::supports_sha()) {
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3938
      __ fast_sha256(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4,
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3939
        buf, state, ofs, limit, rsp, multi_block, shuf_mask);
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3940
    } else if (VM_Version::supports_avx2()) {
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3941
      __ sha256_AVX2(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4,
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3942
        buf, state, ofs, limit, rsp, multi_block, shuf_mask);
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  3943
    }
36555
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3944
    __ addptr(rsp, 4 * wordSize);
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  3945
    __ vzeroupper();
36555
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3946
    __ leave();
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3947
    __ ret(0);
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3948
    return start;
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3949
  }
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  3950
42039
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3951
  address generate_sha512_implCompress(bool multi_block, const char *name) {
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3952
    assert(VM_Version::supports_avx2(), "");
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3953
    assert(VM_Version::supports_bmi2(), "");
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3954
    __ align(CodeEntryAlignment);
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3955
    StubCodeMark mark(this, "StubRoutines", name);
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3956
    address start = __ pc();
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3957
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3958
    Register buf = c_rarg0;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3959
    Register state = c_rarg1;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3960
    Register ofs = c_rarg2;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3961
    Register limit = c_rarg3;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3962
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3963
    const XMMRegister msg = xmm0;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3964
    const XMMRegister state0 = xmm1;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3965
    const XMMRegister state1 = xmm2;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3966
    const XMMRegister msgtmp0 = xmm3;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3967
    const XMMRegister msgtmp1 = xmm4;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3968
    const XMMRegister msgtmp2 = xmm5;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3969
    const XMMRegister msgtmp3 = xmm6;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3970
    const XMMRegister msgtmp4 = xmm7;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3971
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3972
    const XMMRegister shuf_mask = xmm8;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3973
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3974
    __ enter();
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3975
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3976
    __ sha512_AVX2(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4,
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3977
    buf, state, ofs, limit, rsp, multi_block, shuf_mask);
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3978
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  3979
    __ vzeroupper();
42039
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3980
    __ leave();
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3981
    __ ret(0);
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3982
    return start;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3983
  }
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  3984
35154
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3985
  // This is a version of CTR/AES crypt which does 6 blocks in a loop at a time
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3986
  // to hide instruction latency
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3987
  //
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3988
  // Arguments:
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3989
  //
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3990
  // Inputs:
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3991
  //   c_rarg0   - source byte array address
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3992
  //   c_rarg1   - destination byte array address
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3993
  //   c_rarg2   - K (key) in little endian int array
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3994
  //   c_rarg3   - counter vector byte array address
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3995
  //   Linux
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3996
  //     c_rarg4   -          input length
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3997
  //     c_rarg5   -          saved encryptedCounter start
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3998
  //     rbp + 6 * wordSize - saved used length
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  3999
  //   Windows
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4000
  //     rbp + 6 * wordSize - input length
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4001
  //     rbp + 7 * wordSize - saved encryptedCounter start
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4002
  //     rbp + 8 * wordSize - saved used length
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4003
  //
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4004
  // Output:
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4005
  //   rax       - input length
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4006
  //
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4007
  address generate_counterMode_AESCrypt_Parallel() {
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4008
    assert(UseAES, "need AES instructions and misaligned SSE support");
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4009
    __ align(CodeEntryAlignment);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4010
    StubCodeMark mark(this, "StubRoutines", "counterMode_AESCrypt");
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4011
    address start = __ pc();
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4012
    const Register from = c_rarg0; // source array address
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4013
    const Register to = c_rarg1; // destination array address
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4014
    const Register key = c_rarg2; // key array address
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4015
    const Register counter = c_rarg3; // counter byte array initialized from counter array address
35537
bed5e2dc57a1 8146581: Minor corrections to the patch submitted for earlier bug id - 8143925
kvn
parents: 35154
diff changeset
  4016
                                      // and updated with the incremented counter in the end
35154
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4017
#ifndef _WIN64
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4018
    const Register len_reg = c_rarg4;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4019
    const Register saved_encCounter_start = c_rarg5;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4020
    const Register used_addr = r10;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4021
    const Address  used_mem(rbp, 2 * wordSize);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4022
    const Register used = r11;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4023
#else
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4024
    const Address len_mem(rbp, 6 * wordSize); // length is on stack on Win64
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4025
    const Address saved_encCounter_mem(rbp, 7 * wordSize); // length is on stack on Win64
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4026
    const Address used_mem(rbp, 8 * wordSize); // length is on stack on Win64
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4027
    const Register len_reg = r10; // pick the first volatile windows register
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4028
    const Register saved_encCounter_start = r11;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4029
    const Register used_addr = r13;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4030
    const Register used = r14;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4031
#endif
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4032
    const Register pos = rax;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4033
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4034
    const int PARALLEL_FACTOR = 6;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4035
    const XMMRegister xmm_counter_shuf_mask = xmm0;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4036
    const XMMRegister xmm_key_shuf_mask = xmm1; // used temporarily to swap key bytes up front
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4037
    const XMMRegister xmm_curr_counter = xmm2;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4038
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4039
    const XMMRegister xmm_key_tmp0 = xmm3;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4040
    const XMMRegister xmm_key_tmp1 = xmm4;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4041
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4042
    // registers holding the four results in the parallelized loop
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4043
    const XMMRegister xmm_result0 = xmm5;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4044
    const XMMRegister xmm_result1 = xmm6;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4045
    const XMMRegister xmm_result2 = xmm7;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4046
    const XMMRegister xmm_result3 = xmm8;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4047
    const XMMRegister xmm_result4 = xmm9;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4048
    const XMMRegister xmm_result5 = xmm10;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4049
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4050
    const XMMRegister xmm_from0 = xmm11;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4051
    const XMMRegister xmm_from1 = xmm12;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4052
    const XMMRegister xmm_from2 = xmm13;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4053
    const XMMRegister xmm_from3 = xmm14; //the last one is xmm14. we have to preserve it on WIN64.
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4054
    const XMMRegister xmm_from4 = xmm3; //reuse xmm3~4. Because xmm_key_tmp0~1 are useless when loading input text
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4055
    const XMMRegister xmm_from5 = xmm4;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4056
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4057
    //for key_128, key_192, key_256
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4058
    const int rounds[3] = {10, 12, 14};
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4059
    Label L_exit_preLoop, L_preLoop_start;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4060
    Label L_multiBlock_loopTop[3];
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4061
    Label L_singleBlockLoopTop[3];
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4062
    Label L__incCounter[3][6]; //for 6 blocks
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4063
    Label L__incCounter_single[3]; //for single block, key128, key192, key256
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4064
    Label L_processTail_insr[3], L_processTail_4_insr[3], L_processTail_2_insr[3], L_processTail_1_insr[3], L_processTail_exit_insr[3];
51756
4bd35a5ec694 8210676: Remove some unused Label variables
mikael
parents: 50860
diff changeset
  4065
    Label L_processTail_4_extr[3], L_processTail_2_extr[3], L_processTail_1_extr[3], L_processTail_exit_extr[3];
35154
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4066
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4067
    Label L_exit;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4068
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4069
    __ enter(); // required for proper stackwalking of RuntimeStub frame
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4070
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4071
#ifdef _WIN64
41333
ce08d64b41c7 8078122: YMM registers upper 128 bits may get clobbered by a JNI call on windows
kvn
parents: 40644
diff changeset
  4072
    // allocate spill slots for r13, r14
ce08d64b41c7 8078122: YMM registers upper 128 bits may get clobbered by a JNI call on windows
kvn
parents: 40644
diff changeset
  4073
    enum {
ce08d64b41c7 8078122: YMM registers upper 128 bits may get clobbered by a JNI call on windows
kvn
parents: 40644
diff changeset
  4074
        saved_r13_offset,
ce08d64b41c7 8078122: YMM registers upper 128 bits may get clobbered by a JNI call on windows
kvn
parents: 40644
diff changeset
  4075
        saved_r14_offset
ce08d64b41c7 8078122: YMM registers upper 128 bits may get clobbered by a JNI call on windows
kvn
parents: 40644
diff changeset
  4076
    };
ce08d64b41c7 8078122: YMM registers upper 128 bits may get clobbered by a JNI call on windows
kvn
parents: 40644
diff changeset
  4077
    __ subptr(rsp, 2 * wordSize);
ce08d64b41c7 8078122: YMM registers upper 128 bits may get clobbered by a JNI call on windows
kvn
parents: 40644
diff changeset
  4078
    __ movptr(Address(rsp, saved_r13_offset * wordSize), r13);
ce08d64b41c7 8078122: YMM registers upper 128 bits may get clobbered by a JNI call on windows
kvn
parents: 40644
diff changeset
  4079
    __ movptr(Address(rsp, saved_r14_offset * wordSize), r14);
35154
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4080
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4081
    // on win64, fill len_reg from stack position
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4082
    __ movl(len_reg, len_mem);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4083
    __ movptr(saved_encCounter_start, saved_encCounter_mem);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4084
    __ movptr(used_addr, used_mem);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4085
    __ movl(used, Address(used_addr, 0));
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4086
#else
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4087
    __ push(len_reg); // Save
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4088
    __ movptr(used_addr, used_mem);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4089
    __ movl(used, Address(used_addr, 0));
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4090
#endif
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4091
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4092
    __ push(rbx); // Save RBX
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4093
    __ movdqu(xmm_curr_counter, Address(counter, 0x00)); // initialize counter with initial counter
43423
bcaab17f72a5 8171974: Fix for R10 Register clobbering with usage of ExternalAddress
vdeshpande
parents: 42618
diff changeset
  4094
    __ movdqu(xmm_counter_shuf_mask, ExternalAddress(StubRoutines::x86::counter_shuffle_mask_addr()), pos); // pos as scratch
35154
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4095
    __ pshufb(xmm_curr_counter, xmm_counter_shuf_mask); //counter is shuffled
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4096
    __ movptr(pos, 0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4097
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4098
    // Use the partially used encrpyted counter from last invocation
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4099
    __ BIND(L_preLoop_start);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4100
    __ cmpptr(used, 16);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4101
    __ jcc(Assembler::aboveEqual, L_exit_preLoop);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4102
      __ cmpptr(len_reg, 0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4103
      __ jcc(Assembler::lessEqual, L_exit_preLoop);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4104
      __ movb(rbx, Address(saved_encCounter_start, used));
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4105
      __ xorb(rbx, Address(from, pos));
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4106
      __ movb(Address(to, pos), rbx);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4107
      __ addptr(pos, 1);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4108
      __ addptr(used, 1);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4109
      __ subptr(len_reg, 1);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4110
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4111
    __ jmp(L_preLoop_start);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4112
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4113
    __ BIND(L_exit_preLoop);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4114
    __ movl(Address(used_addr, 0), used);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4115
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4116
    // key length could be only {11, 13, 15} * 4 = {44, 52, 60}
43423
bcaab17f72a5 8171974: Fix for R10 Register clobbering with usage of ExternalAddress
vdeshpande
parents: 42618
diff changeset
  4117
    __ movdqu(xmm_key_shuf_mask, ExternalAddress(StubRoutines::x86::key_shuffle_mask_addr()), rbx); // rbx as scratch
35154
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4118
    __ movl(rbx, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4119
    __ cmpl(rbx, 52);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4120
    __ jcc(Assembler::equal, L_multiBlock_loopTop[1]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4121
    __ cmpl(rbx, 60);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4122
    __ jcc(Assembler::equal, L_multiBlock_loopTop[2]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4123
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4124
#define CTR_DoSix(opc, src_reg)                \
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4125
    __ opc(xmm_result0, src_reg);              \
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4126
    __ opc(xmm_result1, src_reg);              \
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4127
    __ opc(xmm_result2, src_reg);              \
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4128
    __ opc(xmm_result3, src_reg);              \
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4129
    __ opc(xmm_result4, src_reg);              \
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4130
    __ opc(xmm_result5, src_reg);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4131
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4132
    // k == 0 :  generate code for key_128
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4133
    // k == 1 :  generate code for key_192
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4134
    // k == 2 :  generate code for key_256
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4135
    for (int k = 0; k < 3; ++k) {
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4136
      //multi blocks starts here
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4137
      __ align(OptoLoopAlignment);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4138
      __ BIND(L_multiBlock_loopTop[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4139
      __ cmpptr(len_reg, PARALLEL_FACTOR * AESBlockSize); // see if at least PARALLEL_FACTOR blocks left
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4140
      __ jcc(Assembler::less, L_singleBlockLoopTop[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4141
      load_key(xmm_key_tmp0, key, 0x00, xmm_key_shuf_mask);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4142
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4143
      //load, then increase counters
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4144
      CTR_DoSix(movdqa, xmm_curr_counter);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4145
      inc_counter(rbx, xmm_result1, 0x01, L__incCounter[k][0]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4146
      inc_counter(rbx, xmm_result2, 0x02, L__incCounter[k][1]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4147
      inc_counter(rbx, xmm_result3, 0x03, L__incCounter[k][2]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4148
      inc_counter(rbx, xmm_result4, 0x04, L__incCounter[k][3]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4149
      inc_counter(rbx, xmm_result5,  0x05, L__incCounter[k][4]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4150
      inc_counter(rbx, xmm_curr_counter, 0x06, L__incCounter[k][5]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4151
      CTR_DoSix(pshufb, xmm_counter_shuf_mask); // after increased, shuffled counters back for PXOR
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4152
      CTR_DoSix(pxor, xmm_key_tmp0);   //PXOR with Round 0 key
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4153
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4154
      //load two ROUND_KEYs at a time
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4155
      for (int i = 1; i < rounds[k]; ) {
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4156
        load_key(xmm_key_tmp1, key, (0x10 * i), xmm_key_shuf_mask);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4157
        load_key(xmm_key_tmp0, key, (0x10 * (i+1)), xmm_key_shuf_mask);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4158
        CTR_DoSix(aesenc, xmm_key_tmp1);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4159
        i++;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4160
        if (i != rounds[k]) {
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4161
          CTR_DoSix(aesenc, xmm_key_tmp0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4162
        } else {
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4163
          CTR_DoSix(aesenclast, xmm_key_tmp0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4164
        }
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4165
        i++;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4166
      }
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4167
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4168
      // get next PARALLEL_FACTOR blocks into xmm_result registers
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4169
      __ movdqu(xmm_from0, Address(from, pos, Address::times_1, 0 * AESBlockSize));
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4170
      __ movdqu(xmm_from1, Address(from, pos, Address::times_1, 1 * AESBlockSize));
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4171
      __ movdqu(xmm_from2, Address(from, pos, Address::times_1, 2 * AESBlockSize));
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4172
      __ movdqu(xmm_from3, Address(from, pos, Address::times_1, 3 * AESBlockSize));
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4173
      __ movdqu(xmm_from4, Address(from, pos, Address::times_1, 4 * AESBlockSize));
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4174
      __ movdqu(xmm_from5, Address(from, pos, Address::times_1, 5 * AESBlockSize));
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4175
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4176
      __ pxor(xmm_result0, xmm_from0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4177
      __ pxor(xmm_result1, xmm_from1);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4178
      __ pxor(xmm_result2, xmm_from2);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4179
      __ pxor(xmm_result3, xmm_from3);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4180
      __ pxor(xmm_result4, xmm_from4);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4181
      __ pxor(xmm_result5, xmm_from5);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4182
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4183
      // store 6 results into the next 64 bytes of output
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4184
      __ movdqu(Address(to, pos, Address::times_1, 0 * AESBlockSize), xmm_result0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4185
      __ movdqu(Address(to, pos, Address::times_1, 1 * AESBlockSize), xmm_result1);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4186
      __ movdqu(Address(to, pos, Address::times_1, 2 * AESBlockSize), xmm_result2);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4187
      __ movdqu(Address(to, pos, Address::times_1, 3 * AESBlockSize), xmm_result3);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4188
      __ movdqu(Address(to, pos, Address::times_1, 4 * AESBlockSize), xmm_result4);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4189
      __ movdqu(Address(to, pos, Address::times_1, 5 * AESBlockSize), xmm_result5);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4190
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4191
      __ addptr(pos, PARALLEL_FACTOR * AESBlockSize); // increase the length of crypt text
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4192
      __ subptr(len_reg, PARALLEL_FACTOR * AESBlockSize); // decrease the remaining length
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4193
      __ jmp(L_multiBlock_loopTop[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4194
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4195
      // singleBlock starts here
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4196
      __ align(OptoLoopAlignment);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4197
      __ BIND(L_singleBlockLoopTop[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4198
      __ cmpptr(len_reg, 0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4199
      __ jcc(Assembler::lessEqual, L_exit);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4200
      load_key(xmm_key_tmp0, key, 0x00, xmm_key_shuf_mask);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4201
      __ movdqa(xmm_result0, xmm_curr_counter);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4202
      inc_counter(rbx, xmm_curr_counter, 0x01, L__incCounter_single[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4203
      __ pshufb(xmm_result0, xmm_counter_shuf_mask);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4204
      __ pxor(xmm_result0, xmm_key_tmp0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4205
      for (int i = 1; i < rounds[k]; i++) {
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4206
        load_key(xmm_key_tmp0, key, (0x10 * i), xmm_key_shuf_mask);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4207
        __ aesenc(xmm_result0, xmm_key_tmp0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4208
      }
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4209
      load_key(xmm_key_tmp0, key, (rounds[k] * 0x10), xmm_key_shuf_mask);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4210
      __ aesenclast(xmm_result0, xmm_key_tmp0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4211
      __ cmpptr(len_reg, AESBlockSize);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4212
      __ jcc(Assembler::less, L_processTail_insr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4213
        __ movdqu(xmm_from0, Address(from, pos, Address::times_1, 0 * AESBlockSize));
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4214
        __ pxor(xmm_result0, xmm_from0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4215
        __ movdqu(Address(to, pos, Address::times_1, 0 * AESBlockSize), xmm_result0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4216
        __ addptr(pos, AESBlockSize);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4217
        __ subptr(len_reg, AESBlockSize);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4218
        __ jmp(L_singleBlockLoopTop[k]);
35537
bed5e2dc57a1 8146581: Minor corrections to the patch submitted for earlier bug id - 8143925
kvn
parents: 35154
diff changeset
  4219
      __ BIND(L_processTail_insr[k]);                               // Process the tail part of the input array
bed5e2dc57a1 8146581: Minor corrections to the patch submitted for earlier bug id - 8143925
kvn
parents: 35154
diff changeset
  4220
        __ addptr(pos, len_reg);                                    // 1. Insert bytes from src array into xmm_from0 register
35154
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4221
        __ testptr(len_reg, 8);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4222
        __ jcc(Assembler::zero, L_processTail_4_insr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4223
          __ subptr(pos,8);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4224
          __ pinsrq(xmm_from0, Address(from, pos), 0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4225
        __ BIND(L_processTail_4_insr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4226
        __ testptr(len_reg, 4);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4227
        __ jcc(Assembler::zero, L_processTail_2_insr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4228
          __ subptr(pos,4);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4229
          __ pslldq(xmm_from0, 4);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4230
          __ pinsrd(xmm_from0, Address(from, pos), 0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4231
        __ BIND(L_processTail_2_insr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4232
        __ testptr(len_reg, 2);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4233
        __ jcc(Assembler::zero, L_processTail_1_insr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4234
          __ subptr(pos, 2);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4235
          __ pslldq(xmm_from0, 2);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4236
          __ pinsrw(xmm_from0, Address(from, pos), 0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4237
        __ BIND(L_processTail_1_insr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4238
        __ testptr(len_reg, 1);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4239
        __ jcc(Assembler::zero, L_processTail_exit_insr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4240
          __ subptr(pos, 1);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4241
          __ pslldq(xmm_from0, 1);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4242
          __ pinsrb(xmm_from0, Address(from, pos), 0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4243
        __ BIND(L_processTail_exit_insr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4244
35537
bed5e2dc57a1 8146581: Minor corrections to the patch submitted for earlier bug id - 8143925
kvn
parents: 35154
diff changeset
  4245
        __ movdqu(Address(saved_encCounter_start, 0), xmm_result0);  // 2. Perform pxor of the encrypted counter and plaintext Bytes.
bed5e2dc57a1 8146581: Minor corrections to the patch submitted for earlier bug id - 8143925
kvn
parents: 35154
diff changeset
  4246
        __ pxor(xmm_result0, xmm_from0);                             //    Also the encrypted counter is saved for next invocation.
35154
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4247
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4248
        __ testptr(len_reg, 8);
35537
bed5e2dc57a1 8146581: Minor corrections to the patch submitted for earlier bug id - 8143925
kvn
parents: 35154
diff changeset
  4249
        __ jcc(Assembler::zero, L_processTail_4_extr[k]);            // 3. Extract bytes from xmm_result0 into the dest. array
35154
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4250
          __ pextrq(Address(to, pos), xmm_result0, 0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4251
          __ psrldq(xmm_result0, 8);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4252
          __ addptr(pos, 8);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4253
        __ BIND(L_processTail_4_extr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4254
        __ testptr(len_reg, 4);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4255
        __ jcc(Assembler::zero, L_processTail_2_extr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4256
          __ pextrd(Address(to, pos), xmm_result0, 0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4257
          __ psrldq(xmm_result0, 4);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4258
          __ addptr(pos, 4);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4259
        __ BIND(L_processTail_2_extr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4260
        __ testptr(len_reg, 2);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4261
        __ jcc(Assembler::zero, L_processTail_1_extr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4262
          __ pextrw(Address(to, pos), xmm_result0, 0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4263
          __ psrldq(xmm_result0, 2);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4264
          __ addptr(pos, 2);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4265
        __ BIND(L_processTail_1_extr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4266
        __ testptr(len_reg, 1);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4267
        __ jcc(Assembler::zero, L_processTail_exit_extr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4268
          __ pextrb(Address(to, pos), xmm_result0, 0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4269
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4270
        __ BIND(L_processTail_exit_extr[k]);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4271
        __ movl(Address(used_addr, 0), len_reg);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4272
        __ jmp(L_exit);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4273
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4274
    }
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4275
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4276
    __ BIND(L_exit);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4277
    __ pshufb(xmm_curr_counter, xmm_counter_shuf_mask); //counter is shuffled back.
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4278
    __ movdqu(Address(counter, 0), xmm_curr_counter); //save counter back
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4279
    __ pop(rbx); // pop the saved RBX.
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4280
#ifdef _WIN64
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4281
    __ movl(rax, len_mem);
41333
ce08d64b41c7 8078122: YMM registers upper 128 bits may get clobbered by a JNI call on windows
kvn
parents: 40644
diff changeset
  4282
    __ movptr(r13, Address(rsp, saved_r13_offset * wordSize));
ce08d64b41c7 8078122: YMM registers upper 128 bits may get clobbered by a JNI call on windows
kvn
parents: 40644
diff changeset
  4283
    __ movptr(r14, Address(rsp, saved_r14_offset * wordSize));
ce08d64b41c7 8078122: YMM registers upper 128 bits may get clobbered by a JNI call on windows
kvn
parents: 40644
diff changeset
  4284
    __ addptr(rsp, 2 * wordSize);
35154
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4285
#else
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4286
    __ pop(rax); // return 'len'
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4287
#endif
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4288
    __ leave(); // required for proper stackwalking of RuntimeStub frame
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4289
    __ ret(0);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4290
    return start;
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  4291
  }
31404
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4292
50699
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4293
void roundDec(XMMRegister xmm_reg) {
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4294
  __ vaesdec(xmm1, xmm1, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4295
  __ vaesdec(xmm2, xmm2, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4296
  __ vaesdec(xmm3, xmm3, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4297
  __ vaesdec(xmm4, xmm4, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4298
  __ vaesdec(xmm5, xmm5, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4299
  __ vaesdec(xmm6, xmm6, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4300
  __ vaesdec(xmm7, xmm7, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4301
  __ vaesdec(xmm8, xmm8, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4302
}
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4303
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4304
void roundDeclast(XMMRegister xmm_reg) {
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4305
  __ vaesdeclast(xmm1, xmm1, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4306
  __ vaesdeclast(xmm2, xmm2, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4307
  __ vaesdeclast(xmm3, xmm3, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4308
  __ vaesdeclast(xmm4, xmm4, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4309
  __ vaesdeclast(xmm5, xmm5, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4310
  __ vaesdeclast(xmm6, xmm6, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4311
  __ vaesdeclast(xmm7, xmm7, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4312
  __ vaesdeclast(xmm8, xmm8, xmm_reg, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4313
}
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4314
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4315
  void ev_load_key(XMMRegister xmmdst, Register key, int offset, XMMRegister xmm_shuf_mask = NULL) {
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4316
    __ movdqu(xmmdst, Address(key, offset));
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4317
    if (xmm_shuf_mask != NULL) {
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4318
      __ pshufb(xmmdst, xmm_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4319
    } else {
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4320
      __ pshufb(xmmdst, ExternalAddress(StubRoutines::x86::key_shuffle_mask_addr()));
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4321
    }
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4322
    __ evshufi64x2(xmmdst, xmmdst, xmmdst, 0x0, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4323
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4324
  }
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4325
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4326
address generate_cipherBlockChaining_decryptVectorAESCrypt() {
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4327
    assert(VM_Version::supports_vaes(), "need AES instructions and misaligned SSE support");
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4328
    __ align(CodeEntryAlignment);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4329
    StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_decryptAESCrypt");
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4330
    address start = __ pc();
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4331
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4332
    const Register from = c_rarg0;  // source array address
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4333
    const Register to = c_rarg1;  // destination array address
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4334
    const Register key = c_rarg2;  // key array address
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4335
    const Register rvec = c_rarg3;  // r byte array initialized from initvector array address
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4336
    // and left with the results of the last encryption block
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4337
#ifndef _WIN64
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4338
    const Register len_reg = c_rarg4;  // src len (must be multiple of blocksize 16)
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4339
#else
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4340
    const Address  len_mem(rbp, 6 * wordSize);  // length is on stack on Win64
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4341
    const Register len_reg = r11;      // pick the volatile windows register
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4342
#endif
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4343
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4344
    Label Loop, Loop1, L_128, L_256, L_192, KEY_192, KEY_256, Loop2, Lcbc_dec_rem_loop,
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4345
          Lcbc_dec_rem_last, Lcbc_dec_ret, Lcbc_dec_rem, Lcbc_exit;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4346
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4347
    __ enter();
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4348
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4349
#ifdef _WIN64
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4350
  // on win64, fill len_reg from stack position
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4351
    __ movl(len_reg, len_mem);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4352
#else
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4353
    __ push(len_reg); // Save
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4354
#endif
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4355
    __ push(rbx);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4356
    __ vzeroupper();
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4357
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4358
    // Temporary variable declaration for swapping key bytes
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4359
    const XMMRegister xmm_key_shuf_mask = xmm1;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4360
    __ movdqu(xmm_key_shuf_mask, ExternalAddress(StubRoutines::x86::key_shuffle_mask_addr()));
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4361
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4362
    // Calculate number of rounds from key size: 44 for 10-rounds, 52 for 12-rounds, 60 for 14-rounds
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4363
    const Register rounds = rbx;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4364
    __ movl(rounds, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4365
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4366
    const XMMRegister IV = xmm0;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4367
    // Load IV and broadcast value to 512-bits
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4368
    __ evbroadcasti64x2(IV, Address(rvec, 0), Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4369
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4370
    // Temporary variables for storing round keys
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4371
    const XMMRegister RK0 = xmm30;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4372
    const XMMRegister RK1 = xmm9;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4373
    const XMMRegister RK2 = xmm18;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4374
    const XMMRegister RK3 = xmm19;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4375
    const XMMRegister RK4 = xmm20;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4376
    const XMMRegister RK5 = xmm21;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4377
    const XMMRegister RK6 = xmm22;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4378
    const XMMRegister RK7 = xmm23;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4379
    const XMMRegister RK8 = xmm24;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4380
    const XMMRegister RK9 = xmm25;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4381
    const XMMRegister RK10 = xmm26;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4382
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4383
     // Load and shuffle key
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4384
    // the java expanded key ordering is rotated one position from what we want
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4385
    // so we start from 1*16 here and hit 0*16 last
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4386
    ev_load_key(RK1, key, 1 * 16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4387
    ev_load_key(RK2, key, 2 * 16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4388
    ev_load_key(RK3, key, 3 * 16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4389
    ev_load_key(RK4, key, 4 * 16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4390
    ev_load_key(RK5, key, 5 * 16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4391
    ev_load_key(RK6, key, 6 * 16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4392
    ev_load_key(RK7, key, 7 * 16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4393
    ev_load_key(RK8, key, 8 * 16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4394
    ev_load_key(RK9, key, 9 * 16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4395
    ev_load_key(RK10, key, 10 * 16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4396
    ev_load_key(RK0, key, 0*16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4397
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4398
    // Variables for storing source cipher text
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4399
    const XMMRegister S0 = xmm10;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4400
    const XMMRegister S1 = xmm11;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4401
    const XMMRegister S2 = xmm12;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4402
    const XMMRegister S3 = xmm13;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4403
    const XMMRegister S4 = xmm14;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4404
    const XMMRegister S5 = xmm15;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4405
    const XMMRegister S6 = xmm16;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4406
    const XMMRegister S7 = xmm17;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4407
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4408
    // Variables for storing decrypted text
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4409
    const XMMRegister B0 = xmm1;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4410
    const XMMRegister B1 = xmm2;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4411
    const XMMRegister B2 = xmm3;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4412
    const XMMRegister B3 = xmm4;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4413
    const XMMRegister B4 = xmm5;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4414
    const XMMRegister B5 = xmm6;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4415
    const XMMRegister B6 = xmm7;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4416
    const XMMRegister B7 = xmm8;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4417
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4418
    __ cmpl(rounds, 44);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4419
    __ jcc(Assembler::greater, KEY_192);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4420
    __ jmp(Loop);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4421
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4422
    __ BIND(KEY_192);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4423
    const XMMRegister RK11 = xmm27;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4424
    const XMMRegister RK12 = xmm28;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4425
    ev_load_key(RK11, key, 11*16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4426
    ev_load_key(RK12, key, 12*16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4427
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4428
    __ cmpl(rounds, 52);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4429
    __ jcc(Assembler::greater, KEY_256);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4430
    __ jmp(Loop);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4431
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4432
    __ BIND(KEY_256);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4433
    const XMMRegister RK13 = xmm29;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4434
    const XMMRegister RK14 = xmm31;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4435
    ev_load_key(RK13, key, 13*16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4436
    ev_load_key(RK14, key, 14*16, xmm_key_shuf_mask);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4437
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4438
    __ BIND(Loop);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4439
    __ cmpl(len_reg, 512);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4440
    __ jcc(Assembler::below, Lcbc_dec_rem);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4441
    __ BIND(Loop1);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4442
    __ subl(len_reg, 512);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4443
    __ evmovdquq(S0, Address(from, 0 * 64), Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4444
    __ evmovdquq(S1, Address(from, 1 * 64), Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4445
    __ evmovdquq(S2, Address(from, 2 * 64), Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4446
    __ evmovdquq(S3, Address(from, 3 * 64), Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4447
    __ evmovdquq(S4, Address(from, 4 * 64), Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4448
    __ evmovdquq(S5, Address(from, 5 * 64), Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4449
    __ evmovdquq(S6, Address(from, 6 * 64), Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4450
    __ evmovdquq(S7, Address(from, 7 * 64), Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4451
    __ leaq(from, Address(from, 8 * 64));
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4452
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4453
    __ evpxorq(B0, S0, RK1, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4454
    __ evpxorq(B1, S1, RK1, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4455
    __ evpxorq(B2, S2, RK1, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4456
    __ evpxorq(B3, S3, RK1, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4457
    __ evpxorq(B4, S4, RK1, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4458
    __ evpxorq(B5, S5, RK1, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4459
    __ evpxorq(B6, S6, RK1, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4460
    __ evpxorq(B7, S7, RK1, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4461
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4462
    __ evalignq(IV, S0, IV, 0x06);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4463
    __ evalignq(S0, S1, S0, 0x06);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4464
    __ evalignq(S1, S2, S1, 0x06);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4465
    __ evalignq(S2, S3, S2, 0x06);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4466
    __ evalignq(S3, S4, S3, 0x06);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4467
    __ evalignq(S4, S5, S4, 0x06);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4468
    __ evalignq(S5, S6, S5, 0x06);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4469
    __ evalignq(S6, S7, S6, 0x06);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4470
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4471
    roundDec(RK2);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4472
    roundDec(RK3);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4473
    roundDec(RK4);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4474
    roundDec(RK5);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4475
    roundDec(RK6);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4476
    roundDec(RK7);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4477
    roundDec(RK8);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4478
    roundDec(RK9);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4479
    roundDec(RK10);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4480
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4481
    __ cmpl(rounds, 44);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4482
    __ jcc(Assembler::belowEqual, L_128);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4483
    roundDec(RK11);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4484
    roundDec(RK12);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4485
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4486
    __ cmpl(rounds, 52);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4487
    __ jcc(Assembler::belowEqual, L_192);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4488
    roundDec(RK13);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4489
    roundDec(RK14);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4490
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4491
    __ BIND(L_256);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4492
    roundDeclast(RK0);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4493
    __ jmp(Loop2);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4494
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4495
    __ BIND(L_128);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4496
    roundDeclast(RK0);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4497
    __ jmp(Loop2);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4498
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4499
    __ BIND(L_192);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4500
    roundDeclast(RK0);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4501
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4502
    __ BIND(Loop2);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4503
    __ evpxorq(B0, B0, IV, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4504
    __ evpxorq(B1, B1, S0, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4505
    __ evpxorq(B2, B2, S1, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4506
    __ evpxorq(B3, B3, S2, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4507
    __ evpxorq(B4, B4, S3, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4508
    __ evpxorq(B5, B5, S4, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4509
    __ evpxorq(B6, B6, S5, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4510
    __ evpxorq(B7, B7, S6, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4511
    __ evmovdquq(IV, S7, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4512
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4513
    __ evmovdquq(Address(to, 0 * 64), B0, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4514
    __ evmovdquq(Address(to, 1 * 64), B1, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4515
    __ evmovdquq(Address(to, 2 * 64), B2, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4516
    __ evmovdquq(Address(to, 3 * 64), B3, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4517
    __ evmovdquq(Address(to, 4 * 64), B4, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4518
    __ evmovdquq(Address(to, 5 * 64), B5, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4519
    __ evmovdquq(Address(to, 6 * 64), B6, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4520
    __ evmovdquq(Address(to, 7 * 64), B7, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4521
    __ leaq(to, Address(to, 8 * 64));
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4522
    __ jmp(Loop);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4523
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4524
    __ BIND(Lcbc_dec_rem);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4525
    __ evshufi64x2(IV, IV, IV, 0x03, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4526
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4527
    __ BIND(Lcbc_dec_rem_loop);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4528
    __ subl(len_reg, 16);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4529
    __ jcc(Assembler::carrySet, Lcbc_dec_ret);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4530
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4531
    __ movdqu(S0, Address(from, 0));
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4532
    __ evpxorq(B0, S0, RK1, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4533
    __ vaesdec(B0, B0, RK2, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4534
    __ vaesdec(B0, B0, RK3, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4535
    __ vaesdec(B0, B0, RK4, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4536
    __ vaesdec(B0, B0, RK5, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4537
    __ vaesdec(B0, B0, RK6, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4538
    __ vaesdec(B0, B0, RK7, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4539
    __ vaesdec(B0, B0, RK8, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4540
    __ vaesdec(B0, B0, RK9, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4541
    __ vaesdec(B0, B0, RK10, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4542
    __ cmpl(rounds, 44);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4543
    __ jcc(Assembler::belowEqual, Lcbc_dec_rem_last);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4544
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4545
    __ vaesdec(B0, B0, RK11, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4546
    __ vaesdec(B0, B0, RK12, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4547
    __ cmpl(rounds, 52);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4548
    __ jcc(Assembler::belowEqual, Lcbc_dec_rem_last);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4549
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4550
    __ vaesdec(B0, B0, RK13, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4551
    __ vaesdec(B0, B0, RK14, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4552
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4553
    __ BIND(Lcbc_dec_rem_last);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4554
    __ vaesdeclast(B0, B0, RK0, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4555
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4556
    __ evpxorq(B0, B0, IV, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4557
    __ evmovdquq(IV, S0, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4558
    __ movdqu(Address(to, 0), B0);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4559
    __ leaq(from, Address(from, 16));
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4560
    __ leaq(to, Address(to, 16));
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4561
    __ jmp(Lcbc_dec_rem_loop);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4562
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4563
    __ BIND(Lcbc_dec_ret);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4564
    __ movdqu(Address(rvec, 0), IV);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4565
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4566
    // Zero out the round keys
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4567
    __ evpxorq(RK0, RK0, RK0, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4568
    __ evpxorq(RK1, RK1, RK1, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4569
    __ evpxorq(RK2, RK2, RK2, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4570
    __ evpxorq(RK3, RK3, RK3, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4571
    __ evpxorq(RK4, RK4, RK4, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4572
    __ evpxorq(RK5, RK5, RK5, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4573
    __ evpxorq(RK6, RK6, RK6, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4574
    __ evpxorq(RK7, RK7, RK7, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4575
    __ evpxorq(RK8, RK8, RK8, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4576
    __ evpxorq(RK9, RK9, RK9, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4577
    __ evpxorq(RK10, RK10, RK10, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4578
    __ cmpl(rounds, 44);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4579
    __ jcc(Assembler::belowEqual, Lcbc_exit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4580
    __ evpxorq(RK11, RK11, RK11, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4581
    __ evpxorq(RK12, RK12, RK12, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4582
    __ cmpl(rounds, 52);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4583
    __ jcc(Assembler::belowEqual, Lcbc_exit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4584
    __ evpxorq(RK13, RK13, RK13, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4585
    __ evpxorq(RK14, RK14, RK14, Assembler::AVX_512bit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4586
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4587
    __ BIND(Lcbc_exit);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4588
    __ pop(rbx);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4589
#ifdef _WIN64
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4590
    __ movl(rax, len_mem);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4591
#else
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4592
    __ pop(rax); // return length
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4593
#endif
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4594
    __ leave(); // required for proper stackwalking of RuntimeStub frame
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4595
    __ ret(0);
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4596
    return start;
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4597
}
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  4598
52990
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4599
// Polynomial x^128+x^127+x^126+x^121+1
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4600
address ghash_polynomial_addr() {
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4601
    __ align(CodeEntryAlignment);
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4602
    StubCodeMark mark(this, "StubRoutines", "_ghash_poly_addr");
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4603
    address start = __ pc();
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4604
    __ emit_data64(0x0000000000000001, relocInfo::none);
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4605
    __ emit_data64(0xc200000000000000, relocInfo::none);
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4606
    return start;
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4607
}
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4608
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4609
address ghash_shufflemask_addr() {
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4610
    __ align(CodeEntryAlignment);
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4611
    StubCodeMark mark(this, "StubRoutines", "_ghash_shuffmask_addr");
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4612
    address start = __ pc();
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4613
    __ emit_data64(0x0f0f0f0f0f0f0f0f, relocInfo::none);
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4614
    __ emit_data64(0x0f0f0f0f0f0f0f0f, relocInfo::none);
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4615
    return start;
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4616
}
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4617
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4618
// Ghash single and multi block operations using AVX instructions
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4619
address generate_avx_ghash_processBlocks() {
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4620
    __ align(CodeEntryAlignment);
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4621
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4622
    StubCodeMark mark(this, "StubRoutines", "ghash_processBlocks");
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4623
    address start = __ pc();
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4624
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4625
    // arguments
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4626
    const Register state = c_rarg0;
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4627
    const Register htbl = c_rarg1;
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4628
    const Register data = c_rarg2;
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4629
    const Register blocks = c_rarg3;
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4630
    __ enter();
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4631
   // Save state before entering routine
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4632
    __ avx_ghash(state, htbl, data, blocks);
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4633
    __ leave(); // required for proper stackwalking of RuntimeStub frame
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4634
    __ ret(0);
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4635
    return start;
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4636
}
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  4637
31404
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4638
  // byte swap x86 long
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4639
  address generate_ghash_long_swap_mask() {
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4640
    __ align(CodeEntryAlignment);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4641
    StubCodeMark mark(this, "StubRoutines", "ghash_long_swap_mask");
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4642
    address start = __ pc();
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4643
    __ emit_data64(0x0f0e0d0c0b0a0908, relocInfo::none );
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4644
    __ emit_data64(0x0706050403020100, relocInfo::none );
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4645
  return start;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4646
  }
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4647
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4648
  // byte swap x86 byte array
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4649
  address generate_ghash_byte_swap_mask() {
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4650
    __ align(CodeEntryAlignment);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4651
    StubCodeMark mark(this, "StubRoutines", "ghash_byte_swap_mask");
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4652
    address start = __ pc();
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4653
    __ emit_data64(0x08090a0b0c0d0e0f, relocInfo::none );
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4654
    __ emit_data64(0x0001020304050607, relocInfo::none );
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4655
  return start;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4656
  }
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4657
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4658
  /* Single and multi-block ghash operations */
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4659
  address generate_ghash_processBlocks() {
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4660
    __ align(CodeEntryAlignment);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4661
    Label L_ghash_loop, L_exit;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4662
    StubCodeMark mark(this, "StubRoutines", "ghash_processBlocks");
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4663
    address start = __ pc();
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4664
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4665
    const Register state        = c_rarg0;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4666
    const Register subkeyH      = c_rarg1;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4667
    const Register data         = c_rarg2;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4668
    const Register blocks       = c_rarg3;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4669
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4670
    const XMMRegister xmm_temp0 = xmm0;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4671
    const XMMRegister xmm_temp1 = xmm1;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4672
    const XMMRegister xmm_temp2 = xmm2;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4673
    const XMMRegister xmm_temp3 = xmm3;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4674
    const XMMRegister xmm_temp4 = xmm4;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4675
    const XMMRegister xmm_temp5 = xmm5;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4676
    const XMMRegister xmm_temp6 = xmm6;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4677
    const XMMRegister xmm_temp7 = xmm7;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4678
    const XMMRegister xmm_temp8 = xmm8;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4679
    const XMMRegister xmm_temp9 = xmm9;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4680
    const XMMRegister xmm_temp10 = xmm10;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4681
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4682
    __ enter();
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4683
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4684
    __ movdqu(xmm_temp10, ExternalAddress(StubRoutines::x86::ghash_long_swap_mask_addr()));
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4685
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4686
    __ movdqu(xmm_temp0, Address(state, 0));
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4687
    __ pshufb(xmm_temp0, xmm_temp10);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4688
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4689
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4690
    __ BIND(L_ghash_loop);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4691
    __ movdqu(xmm_temp2, Address(data, 0));
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4692
    __ pshufb(xmm_temp2, ExternalAddress(StubRoutines::x86::ghash_byte_swap_mask_addr()));
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4693
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4694
    __ movdqu(xmm_temp1, Address(subkeyH, 0));
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4695
    __ pshufb(xmm_temp1, xmm_temp10);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4696
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4697
    __ pxor(xmm_temp0, xmm_temp2);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4698
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4699
    //
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4700
    // Multiply with the hash key
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4701
    //
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4702
    __ movdqu(xmm_temp3, xmm_temp0);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4703
    __ pclmulqdq(xmm_temp3, xmm_temp1, 0);      // xmm3 holds a0*b0
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4704
    __ movdqu(xmm_temp4, xmm_temp0);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4705
    __ pclmulqdq(xmm_temp4, xmm_temp1, 16);     // xmm4 holds a0*b1
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4706
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4707
    __ movdqu(xmm_temp5, xmm_temp0);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4708
    __ pclmulqdq(xmm_temp5, xmm_temp1, 1);      // xmm5 holds a1*b0
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4709
    __ movdqu(xmm_temp6, xmm_temp0);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4710
    __ pclmulqdq(xmm_temp6, xmm_temp1, 17);     // xmm6 holds a1*b1
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4711
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4712
    __ pxor(xmm_temp4, xmm_temp5);      // xmm4 holds a0*b1 + a1*b0
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4713
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4714
    __ movdqu(xmm_temp5, xmm_temp4);    // move the contents of xmm4 to xmm5
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4715
    __ psrldq(xmm_temp4, 8);    // shift by xmm4 64 bits to the right
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4716
    __ pslldq(xmm_temp5, 8);    // shift by xmm5 64 bits to the left
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4717
    __ pxor(xmm_temp3, xmm_temp5);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4718
    __ pxor(xmm_temp6, xmm_temp4);      // Register pair <xmm6:xmm3> holds the result
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4719
                                        // of the carry-less multiplication of
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4720
                                        // xmm0 by xmm1.
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4721
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4722
    // We shift the result of the multiplication by one bit position
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4723
    // to the left to cope for the fact that the bits are reversed.
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4724
    __ movdqu(xmm_temp7, xmm_temp3);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4725
    __ movdqu(xmm_temp8, xmm_temp6);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4726
    __ pslld(xmm_temp3, 1);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4727
    __ pslld(xmm_temp6, 1);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4728
    __ psrld(xmm_temp7, 31);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4729
    __ psrld(xmm_temp8, 31);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4730
    __ movdqu(xmm_temp9, xmm_temp7);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4731
    __ pslldq(xmm_temp8, 4);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4732
    __ pslldq(xmm_temp7, 4);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4733
    __ psrldq(xmm_temp9, 12);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4734
    __ por(xmm_temp3, xmm_temp7);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4735
    __ por(xmm_temp6, xmm_temp8);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4736
    __ por(xmm_temp6, xmm_temp9);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4737
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4738
    //
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4739
    // First phase of the reduction
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4740
    //
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4741
    // Move xmm3 into xmm7, xmm8, xmm9 in order to perform the shifts
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4742
    // independently.
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4743
    __ movdqu(xmm_temp7, xmm_temp3);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4744
    __ movdqu(xmm_temp8, xmm_temp3);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4745
    __ movdqu(xmm_temp9, xmm_temp3);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4746
    __ pslld(xmm_temp7, 31);    // packed right shift shifting << 31
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4747
    __ pslld(xmm_temp8, 30);    // packed right shift shifting << 30
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4748
    __ pslld(xmm_temp9, 25);    // packed right shift shifting << 25
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4749
    __ pxor(xmm_temp7, xmm_temp8);      // xor the shifted versions
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4750
    __ pxor(xmm_temp7, xmm_temp9);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4751
    __ movdqu(xmm_temp8, xmm_temp7);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4752
    __ pslldq(xmm_temp7, 12);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4753
    __ psrldq(xmm_temp8, 4);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4754
    __ pxor(xmm_temp3, xmm_temp7);      // first phase of the reduction complete
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4755
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4756
    //
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4757
    // Second phase of the reduction
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4758
    //
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4759
    // Make 3 copies of xmm3 in xmm2, xmm4, xmm5 for doing these
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4760
    // shift operations.
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4761
    __ movdqu(xmm_temp2, xmm_temp3);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4762
    __ movdqu(xmm_temp4, xmm_temp3);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4763
    __ movdqu(xmm_temp5, xmm_temp3);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4764
    __ psrld(xmm_temp2, 1);     // packed left shifting >> 1
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4765
    __ psrld(xmm_temp4, 2);     // packed left shifting >> 2
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4766
    __ psrld(xmm_temp5, 7);     // packed left shifting >> 7
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4767
    __ pxor(xmm_temp2, xmm_temp4);      // xor the shifted versions
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4768
    __ pxor(xmm_temp2, xmm_temp5);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4769
    __ pxor(xmm_temp2, xmm_temp8);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4770
    __ pxor(xmm_temp3, xmm_temp2);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4771
    __ pxor(xmm_temp6, xmm_temp3);      // the result is in xmm6
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4772
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4773
    __ decrement(blocks);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4774
    __ jcc(Assembler::zero, L_exit);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4775
    __ movdqu(xmm_temp0, xmm_temp6);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4776
    __ addptr(data, 16);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4777
    __ jmp(L_ghash_loop);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4778
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4779
    __ BIND(L_exit);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4780
    __ pshufb(xmm_temp6, xmm_temp10);          // Byte swap 16-byte result
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4781
    __ movdqu(Address(state, 0), xmm_temp6);   // store the result
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4782
    __ leave();
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4783
    __ ret(0);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4784
    return start;
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4785
  }
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  4786
50860
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4787
  //base64 character set
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4788
  address base64_charset_addr() {
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4789
    __ align(CodeEntryAlignment);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4790
    StubCodeMark mark(this, "StubRoutines", "base64_charset");
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4791
    address start = __ pc();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4792
    __ emit_data64(0x0000004200000041, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4793
    __ emit_data64(0x0000004400000043, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4794
    __ emit_data64(0x0000004600000045, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4795
    __ emit_data64(0x0000004800000047, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4796
    __ emit_data64(0x0000004a00000049, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4797
    __ emit_data64(0x0000004c0000004b, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4798
    __ emit_data64(0x0000004e0000004d, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4799
    __ emit_data64(0x000000500000004f, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4800
    __ emit_data64(0x0000005200000051, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4801
    __ emit_data64(0x0000005400000053, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4802
    __ emit_data64(0x0000005600000055, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4803
    __ emit_data64(0x0000005800000057, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4804
    __ emit_data64(0x0000005a00000059, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4805
    __ emit_data64(0x0000006200000061, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4806
    __ emit_data64(0x0000006400000063, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4807
    __ emit_data64(0x0000006600000065, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4808
    __ emit_data64(0x0000006800000067, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4809
    __ emit_data64(0x0000006a00000069, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4810
    __ emit_data64(0x0000006c0000006b, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4811
    __ emit_data64(0x0000006e0000006d, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4812
    __ emit_data64(0x000000700000006f, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4813
    __ emit_data64(0x0000007200000071, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4814
    __ emit_data64(0x0000007400000073, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4815
    __ emit_data64(0x0000007600000075, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4816
    __ emit_data64(0x0000007800000077, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4817
    __ emit_data64(0x0000007a00000079, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4818
    __ emit_data64(0x0000003100000030, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4819
    __ emit_data64(0x0000003300000032, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4820
    __ emit_data64(0x0000003500000034, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4821
    __ emit_data64(0x0000003700000036, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4822
    __ emit_data64(0x0000003900000038, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4823
    __ emit_data64(0x0000002f0000002b, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4824
    return start;
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4825
  }
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4826
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4827
  //base64 url character set
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4828
  address base64url_charset_addr() {
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4829
    __ align(CodeEntryAlignment);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4830
    StubCodeMark mark(this, "StubRoutines", "base64url_charset");
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4831
    address start = __ pc();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4832
    __ emit_data64(0x0000004200000041, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4833
    __ emit_data64(0x0000004400000043, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4834
    __ emit_data64(0x0000004600000045, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4835
    __ emit_data64(0x0000004800000047, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4836
    __ emit_data64(0x0000004a00000049, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4837
    __ emit_data64(0x0000004c0000004b, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4838
    __ emit_data64(0x0000004e0000004d, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4839
    __ emit_data64(0x000000500000004f, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4840
    __ emit_data64(0x0000005200000051, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4841
    __ emit_data64(0x0000005400000053, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4842
    __ emit_data64(0x0000005600000055, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4843
    __ emit_data64(0x0000005800000057, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4844
    __ emit_data64(0x0000005a00000059, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4845
    __ emit_data64(0x0000006200000061, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4846
    __ emit_data64(0x0000006400000063, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4847
    __ emit_data64(0x0000006600000065, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4848
    __ emit_data64(0x0000006800000067, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4849
    __ emit_data64(0x0000006a00000069, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4850
    __ emit_data64(0x0000006c0000006b, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4851
    __ emit_data64(0x0000006e0000006d, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4852
    __ emit_data64(0x000000700000006f, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4853
    __ emit_data64(0x0000007200000071, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4854
    __ emit_data64(0x0000007400000073, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4855
    __ emit_data64(0x0000007600000075, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4856
    __ emit_data64(0x0000007800000077, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4857
    __ emit_data64(0x0000007a00000079, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4858
    __ emit_data64(0x0000003100000030, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4859
    __ emit_data64(0x0000003300000032, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4860
    __ emit_data64(0x0000003500000034, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4861
    __ emit_data64(0x0000003700000036, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4862
    __ emit_data64(0x0000003900000038, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4863
    __ emit_data64(0x0000005f0000002d, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4864
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4865
    return start;
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4866
  }
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4867
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4868
  address base64_bswap_mask_addr() {
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4869
    __ align(CodeEntryAlignment);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4870
    StubCodeMark mark(this, "StubRoutines", "bswap_mask_base64");
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4871
    address start = __ pc();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4872
    __ emit_data64(0x0504038002010080, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4873
    __ emit_data64(0x0b0a098008070680, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4874
    __ emit_data64(0x0908078006050480, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4875
    __ emit_data64(0x0f0e0d800c0b0a80, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4876
    __ emit_data64(0x0605048003020180, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4877
    __ emit_data64(0x0c0b0a8009080780, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4878
    __ emit_data64(0x0504038002010080, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4879
    __ emit_data64(0x0b0a098008070680, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4880
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4881
    return start;
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4882
  }
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4883
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4884
  address base64_right_shift_mask_addr() {
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4885
    __ align(CodeEntryAlignment);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4886
    StubCodeMark mark(this, "StubRoutines", "right_shift_mask");
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4887
    address start = __ pc();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4888
    __ emit_data64(0x0006000400020000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4889
    __ emit_data64(0x0006000400020000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4890
    __ emit_data64(0x0006000400020000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4891
    __ emit_data64(0x0006000400020000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4892
    __ emit_data64(0x0006000400020000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4893
    __ emit_data64(0x0006000400020000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4894
    __ emit_data64(0x0006000400020000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4895
    __ emit_data64(0x0006000400020000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4896
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4897
    return start;
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4898
  }
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4899
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4900
  address base64_left_shift_mask_addr() {
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4901
    __ align(CodeEntryAlignment);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4902
    StubCodeMark mark(this, "StubRoutines", "left_shift_mask");
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4903
    address start = __ pc();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4904
    __ emit_data64(0x0000000200040000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4905
    __ emit_data64(0x0000000200040000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4906
    __ emit_data64(0x0000000200040000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4907
    __ emit_data64(0x0000000200040000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4908
    __ emit_data64(0x0000000200040000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4909
    __ emit_data64(0x0000000200040000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4910
    __ emit_data64(0x0000000200040000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4911
    __ emit_data64(0x0000000200040000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4912
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4913
    return start;
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4914
  }
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4915
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4916
  address base64_and_mask_addr() {
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4917
    __ align(CodeEntryAlignment);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4918
    StubCodeMark mark(this, "StubRoutines", "and_mask");
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4919
    address start = __ pc();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4920
    __ emit_data64(0x3f003f003f000000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4921
    __ emit_data64(0x3f003f003f000000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4922
    __ emit_data64(0x3f003f003f000000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4923
    __ emit_data64(0x3f003f003f000000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4924
    __ emit_data64(0x3f003f003f000000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4925
    __ emit_data64(0x3f003f003f000000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4926
    __ emit_data64(0x3f003f003f000000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4927
    __ emit_data64(0x3f003f003f000000, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4928
    return start;
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4929
  }
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4930
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4931
  address base64_gather_mask_addr() {
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4932
    __ align(CodeEntryAlignment);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4933
    StubCodeMark mark(this, "StubRoutines", "gather_mask");
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4934
    address start = __ pc();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4935
    __ emit_data64(0xffffffffffffffff, relocInfo::none);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4936
    return start;
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4937
  }
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4938
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4939
// Code for generating Base64 encoding.
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4940
// Intrinsic function prototype in Base64.java:
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4941
// private void encodeBlock(byte[] src, int sp, int sl, byte[] dst, int dp, boolean isURL) {
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4942
  address generate_base64_encodeBlock() {
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4943
    __ align(CodeEntryAlignment);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4944
    StubCodeMark mark(this, "StubRoutines", "implEncode");
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4945
    address start = __ pc();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4946
    __ enter();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4947
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4948
    // Save callee-saved registers before using them
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4949
    __ push(r12);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4950
    __ push(r13);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4951
    __ push(r14);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4952
    __ push(r15);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4953
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4954
    // arguments
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4955
    const Register source = c_rarg0; // Source Array
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4956
    const Register start_offset = c_rarg1; // start offset
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4957
    const Register end_offset = c_rarg2; // end offset
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4958
    const Register dest = c_rarg3; // destination array
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4959
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4960
#ifndef _WIN64
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4961
    const Register dp = c_rarg4;  // Position for writing to dest array
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4962
    const Register isURL = c_rarg5;// Base64 or URL character set
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4963
#else
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4964
    const Address  dp_mem(rbp, 6 * wordSize);  // length is on stack on Win64
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4965
    const Address isURL_mem(rbp, 7 * wordSize);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4966
    const Register isURL = r10;      // pick the volatile windows register
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4967
    const Register dp = r12;
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4968
    __ movl(dp, dp_mem);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4969
    __ movl(isURL, isURL_mem);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4970
#endif
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4971
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4972
    const Register length = r14;
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4973
    Label L_process80, L_process32, L_process3, L_exit, L_processdata;
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4974
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4975
    // calculate length from offsets
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4976
    __ movl(length, end_offset);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4977
    __ subl(length, start_offset);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4978
    __ cmpl(length, 0);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4979
    __ jcc(Assembler::lessEqual, L_exit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4980
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4981
    __ lea(r11, ExternalAddress(StubRoutines::x86::base64_charset_addr()));
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4982
    // check if base64 charset(isURL=0) or base64 url charset(isURL=1) needs to be loaded
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4983
    __ cmpl(isURL, 0);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4984
    __ jcc(Assembler::equal, L_processdata);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4985
    __ lea(r11, ExternalAddress(StubRoutines::x86::base64url_charset_addr()));
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4986
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4987
    // load masks required for encoding data
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4988
    __ BIND(L_processdata);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4989
    __ movdqu(xmm16, ExternalAddress(StubRoutines::x86::base64_gather_mask_addr()));
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4990
    // Set 64 bits of K register.
51976
390f529f4f22 8211251: Default mask register for avx512 instructions
kvn
parents: 51784
diff changeset
  4991
    __ evpcmpeqb(k3, xmm16, xmm16, Assembler::AVX_512bit);
50860
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4992
    __ evmovdquq(xmm12, ExternalAddress(StubRoutines::x86::base64_bswap_mask_addr()), Assembler::AVX_256bit, r13);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4993
    __ evmovdquq(xmm13, ExternalAddress(StubRoutines::x86::base64_right_shift_mask_addr()), Assembler::AVX_512bit, r13);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4994
    __ evmovdquq(xmm14, ExternalAddress(StubRoutines::x86::base64_left_shift_mask_addr()), Assembler::AVX_512bit, r13);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4995
    __ evmovdquq(xmm15, ExternalAddress(StubRoutines::x86::base64_and_mask_addr()), Assembler::AVX_512bit, r13);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4996
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4997
    // Vector Base64 implementation, producing 96 bytes of encoded data
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4998
    __ BIND(L_process80);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  4999
    __ cmpl(length, 80);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5000
    __ jcc(Assembler::below, L_process32);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5001
    __ evmovdquq(xmm0, Address(source, start_offset, Address::times_1, 0), Assembler::AVX_256bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5002
    __ evmovdquq(xmm1, Address(source, start_offset, Address::times_1, 24), Assembler::AVX_256bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5003
    __ evmovdquq(xmm2, Address(source, start_offset, Address::times_1, 48), Assembler::AVX_256bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5004
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5005
    //permute the input data in such a manner that we have continuity of the source
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5006
    __ vpermq(xmm3, xmm0, 148, Assembler::AVX_256bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5007
    __ vpermq(xmm4, xmm1, 148, Assembler::AVX_256bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5008
    __ vpermq(xmm5, xmm2, 148, Assembler::AVX_256bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5009
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5010
    //shuffle input and group 3 bytes of data and to it add 0 as the 4th byte.
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5011
    //we can deal with 12 bytes at a time in a 128 bit register
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5012
    __ vpshufb(xmm3, xmm3, xmm12, Assembler::AVX_256bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5013
    __ vpshufb(xmm4, xmm4, xmm12, Assembler::AVX_256bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5014
    __ vpshufb(xmm5, xmm5, xmm12, Assembler::AVX_256bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5015
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5016
    //convert byte to word. Each 128 bit register will have 6 bytes for processing
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5017
    __ vpmovzxbw(xmm3, xmm3, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5018
    __ vpmovzxbw(xmm4, xmm4, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5019
    __ vpmovzxbw(xmm5, xmm5, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5020
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5021
    // Extract bits in the following pattern 6, 4+2, 2+4, 6 to convert 3, 8 bit numbers to 4, 6 bit numbers
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5022
    __ evpsrlvw(xmm0, xmm3, xmm13,  Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5023
    __ evpsrlvw(xmm1, xmm4, xmm13, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5024
    __ evpsrlvw(xmm2, xmm5, xmm13, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5025
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5026
    __ evpsllvw(xmm3, xmm3, xmm14, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5027
    __ evpsllvw(xmm4, xmm4, xmm14, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5028
    __ evpsllvw(xmm5, xmm5, xmm14, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5029
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5030
    __ vpsrlq(xmm0, xmm0, 8, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5031
    __ vpsrlq(xmm1, xmm1, 8, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5032
    __ vpsrlq(xmm2, xmm2, 8, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5033
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5034
    __ vpsllq(xmm3, xmm3, 8, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5035
    __ vpsllq(xmm4, xmm4, 8, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5036
    __ vpsllq(xmm5, xmm5, 8, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5037
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5038
    __ vpandq(xmm3, xmm3, xmm15, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5039
    __ vpandq(xmm4, xmm4, xmm15, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5040
    __ vpandq(xmm5, xmm5, xmm15, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5041
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5042
    // Get the final 4*6 bits base64 encoding
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5043
    __ vporq(xmm3, xmm3, xmm0, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5044
    __ vporq(xmm4, xmm4, xmm1, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5045
    __ vporq(xmm5, xmm5, xmm2, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5046
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5047
    // Shift
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5048
    __ vpsrlq(xmm3, xmm3, 8, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5049
    __ vpsrlq(xmm4, xmm4, 8, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5050
    __ vpsrlq(xmm5, xmm5, 8, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5051
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5052
    // look up 6 bits in the base64 character set to fetch the encoding
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5053
    // we are converting word to dword as gather instructions need dword indices for looking up encoding
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5054
    __ vextracti64x4(xmm6, xmm3, 0);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5055
    __ vpmovzxwd(xmm0, xmm6, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5056
    __ vextracti64x4(xmm6, xmm3, 1);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5057
    __ vpmovzxwd(xmm1, xmm6, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5058
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5059
    __ vextracti64x4(xmm6, xmm4, 0);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5060
    __ vpmovzxwd(xmm2, xmm6, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5061
    __ vextracti64x4(xmm6, xmm4, 1);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5062
    __ vpmovzxwd(xmm3, xmm6, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5063
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5064
    __ vextracti64x4(xmm4, xmm5, 0);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5065
    __ vpmovzxwd(xmm6, xmm4, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5066
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5067
    __ vextracti64x4(xmm4, xmm5, 1);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5068
    __ vpmovzxwd(xmm7, xmm4, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5069
51976
390f529f4f22 8211251: Default mask register for avx512 instructions
kvn
parents: 51784
diff changeset
  5070
    __ kmovql(k2, k3);
50860
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5071
    __ evpgatherdd(xmm4, k2, Address(r11, xmm0, Address::times_4, 0), Assembler::AVX_512bit);
51976
390f529f4f22 8211251: Default mask register for avx512 instructions
kvn
parents: 51784
diff changeset
  5072
    __ kmovql(k2, k3);
50860
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5073
    __ evpgatherdd(xmm5, k2, Address(r11, xmm1, Address::times_4, 0), Assembler::AVX_512bit);
51976
390f529f4f22 8211251: Default mask register for avx512 instructions
kvn
parents: 51784
diff changeset
  5074
    __ kmovql(k2, k3);
50860
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5075
    __ evpgatherdd(xmm8, k2, Address(r11, xmm2, Address::times_4, 0), Assembler::AVX_512bit);
51976
390f529f4f22 8211251: Default mask register for avx512 instructions
kvn
parents: 51784
diff changeset
  5076
    __ kmovql(k2, k3);
50860
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5077
    __ evpgatherdd(xmm9, k2, Address(r11, xmm3, Address::times_4, 0), Assembler::AVX_512bit);
51976
390f529f4f22 8211251: Default mask register for avx512 instructions
kvn
parents: 51784
diff changeset
  5078
    __ kmovql(k2, k3);
50860
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5079
    __ evpgatherdd(xmm10, k2, Address(r11, xmm6, Address::times_4, 0), Assembler::AVX_512bit);
51976
390f529f4f22 8211251: Default mask register for avx512 instructions
kvn
parents: 51784
diff changeset
  5080
    __ kmovql(k2, k3);
50860
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5081
    __ evpgatherdd(xmm11, k2, Address(r11, xmm7, Address::times_4, 0), Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5082
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5083
    //Down convert dword to byte. Final output is 16*6 = 96 bytes long
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5084
    __ evpmovdb(Address(dest, dp, Address::times_1, 0), xmm4, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5085
    __ evpmovdb(Address(dest, dp, Address::times_1, 16), xmm5, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5086
    __ evpmovdb(Address(dest, dp, Address::times_1, 32), xmm8, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5087
    __ evpmovdb(Address(dest, dp, Address::times_1, 48), xmm9, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5088
    __ evpmovdb(Address(dest, dp, Address::times_1, 64), xmm10, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5089
    __ evpmovdb(Address(dest, dp, Address::times_1, 80), xmm11, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5090
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5091
    __ addq(dest, 96);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5092
    __ addq(source, 72);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5093
    __ subq(length, 72);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5094
    __ jmp(L_process80);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5095
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5096
    // Vector Base64 implementation generating 32 bytes of encoded data
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5097
    __ BIND(L_process32);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5098
    __ cmpl(length, 32);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5099
    __ jcc(Assembler::below, L_process3);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5100
    __ evmovdquq(xmm0, Address(source, start_offset), Assembler::AVX_256bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5101
    __ vpermq(xmm0, xmm0, 148, Assembler::AVX_256bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5102
    __ vpshufb(xmm6, xmm0, xmm12, Assembler::AVX_256bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5103
    __ vpmovzxbw(xmm6, xmm6, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5104
    __ evpsrlvw(xmm2, xmm6, xmm13, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5105
    __ evpsllvw(xmm3, xmm6, xmm14, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5106
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5107
    __ vpsrlq(xmm2, xmm2, 8, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5108
    __ vpsllq(xmm3, xmm3, 8, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5109
    __ vpandq(xmm3, xmm3, xmm15, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5110
    __ vporq(xmm1, xmm2, xmm3, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5111
    __ vpsrlq(xmm1, xmm1, 8, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5112
    __ vextracti64x4(xmm9, xmm1, 0);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5113
    __ vpmovzxwd(xmm6, xmm9, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5114
    __ vextracti64x4(xmm9, xmm1, 1);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5115
    __ vpmovzxwd(xmm5, xmm9,  Assembler::AVX_512bit);
51976
390f529f4f22 8211251: Default mask register for avx512 instructions
kvn
parents: 51784
diff changeset
  5116
    __ kmovql(k2, k3);
50860
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5117
    __ evpgatherdd(xmm8, k2, Address(r11, xmm6, Address::times_4, 0), Assembler::AVX_512bit);
51976
390f529f4f22 8211251: Default mask register for avx512 instructions
kvn
parents: 51784
diff changeset
  5118
    __ kmovql(k2, k3);
50860
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5119
    __ evpgatherdd(xmm10, k2, Address(r11, xmm5, Address::times_4, 0), Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5120
    __ evpmovdb(Address(dest, dp, Address::times_1, 0), xmm8, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5121
    __ evpmovdb(Address(dest, dp, Address::times_1, 16), xmm10, Assembler::AVX_512bit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5122
    __ subq(length, 24);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5123
    __ addq(dest, 32);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5124
    __ addq(source, 24);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5125
    __ jmp(L_process32);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5126
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5127
    // Scalar data processing takes 3 bytes at a time and produces 4 bytes of encoded data
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5128
    /* This code corresponds to the scalar version of the following snippet in Base64.java
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5129
    ** int bits = (src[sp0++] & 0xff) << 16 |(src[sp0++] & 0xff) << 8 |(src[sp0++] & 0xff);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5130
    ** dst[dp0++] = (byte)base64[(bits >> > 18) & 0x3f];
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5131
    ** dst[dp0++] = (byte)base64[(bits >> > 12) & 0x3f];
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5132
    ** dst[dp0++] = (byte)base64[(bits >> > 6) & 0x3f];
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5133
    ** dst[dp0++] = (byte)base64[bits & 0x3f];*/
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5134
    __ BIND(L_process3);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5135
    __ cmpl(length, 3);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5136
    __ jcc(Assembler::below, L_exit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5137
    // Read 1 byte at a time
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5138
    __ movzbl(rax, Address(source, start_offset));
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5139
    __ shll(rax, 0x10);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5140
    __ movl(r15, rax);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5141
    __ movzbl(rax, Address(source, start_offset, Address::times_1, 1));
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5142
    __ shll(rax, 0x8);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5143
    __ movzwl(rax, rax);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5144
    __ orl(r15, rax);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5145
    __ movzbl(rax, Address(source, start_offset, Address::times_1, 2));
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5146
    __ orl(rax, r15);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5147
    // Save 3 bytes read in r15
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5148
    __ movl(r15, rax);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5149
    __ shrl(rax, 0x12);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5150
    __ andl(rax, 0x3f);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5151
    // rax contains the index, r11 contains base64 lookup table
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5152
    __ movb(rax, Address(r11, rax, Address::times_4));
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5153
    // Write the encoded byte to destination
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5154
    __ movb(Address(dest, dp, Address::times_1, 0), rax);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5155
    __ movl(rax, r15);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5156
    __ shrl(rax, 0xc);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5157
    __ andl(rax, 0x3f);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5158
    __ movb(rax, Address(r11, rax, Address::times_4));
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5159
    __ movb(Address(dest, dp, Address::times_1, 1), rax);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5160
    __ movl(rax, r15);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5161
    __ shrl(rax, 0x6);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5162
    __ andl(rax, 0x3f);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5163
    __ movb(rax, Address(r11, rax, Address::times_4));
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5164
    __ movb(Address(dest, dp, Address::times_1, 2), rax);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5165
    __ movl(rax, r15);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5166
    __ andl(rax, 0x3f);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5167
    __ movb(rax, Address(r11, rax, Address::times_4));
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5168
    __ movb(Address(dest, dp, Address::times_1, 3), rax);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5169
    __ subl(length, 3);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5170
    __ addq(dest, 4);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5171
    __ addq(source, 3);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5172
    __ jmp(L_process3);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5173
    __ BIND(L_exit);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5174
    __ pop(r15);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5175
    __ pop(r14);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5176
    __ pop(r13);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5177
    __ pop(r12);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5178
    __ leave();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5179
    __ ret(0);
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5180
    return start;
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5181
  }
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  5182
18507
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5183
  /**
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5184
   *  Arguments:
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5185
   *
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5186
   * Inputs:
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5187
   *   c_rarg0   - int crc
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5188
   *   c_rarg1   - byte* buf
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5189
   *   c_rarg2   - int length
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5190
   *
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5191
   * Ouput:
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5192
   *       rax   - int crc result
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5193
   */
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5194
  address generate_updateBytesCRC32() {
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5195
    assert(UseCRC32Intrinsics, "need AVX and CLMUL instructions");
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5196
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5197
    __ align(CodeEntryAlignment);
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5198
    StubCodeMark mark(this, "StubRoutines", "updateBytesCRC32");
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5199
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5200
    address start = __ pc();
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5201
    // Win64: rcx, rdx, r8, r9 (c_rarg0, c_rarg1, ...)
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5202
    // Unix:  rdi, rsi, rdx, rcx, r8, r9 (c_rarg0, c_rarg1, ...)
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5203
    // rscratch1: r10
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5204
    const Register crc   = c_rarg0;  // crc
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5205
    const Register buf   = c_rarg1;  // source java byte array address
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5206
    const Register len   = c_rarg2;  // length
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5207
    const Register table = c_rarg3;  // crc_table address (reuse register)
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5208
    const Register tmp   = r11;
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5209
    assert_different_registers(crc, buf, len, table, tmp, rax);
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5210
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5211
    BLOCK_COMMENT("Entry:");
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5212
    __ enter(); // required for proper stackwalking of RuntimeStub frame
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5213
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5214
    __ kernel_crc32(crc, buf, len, table, tmp);
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5215
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5216
    __ movl(rax, crc);
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  5217
    __ vzeroupper();
18507
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5218
    __ leave(); // required for proper stackwalking of RuntimeStub frame
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5219
    __ ret(0);
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5220
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5221
    return start;
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5222
  }
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  5223
33066
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5224
  /**
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5225
  *  Arguments:
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5226
  *
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5227
  * Inputs:
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5228
  *   c_rarg0   - int crc
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5229
  *   c_rarg1   - byte* buf
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5230
  *   c_rarg2   - long length
38238
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38135
diff changeset
  5231
  *   c_rarg3   - table_start - optional (present only when doing a library_call,
33066
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5232
  *              not used by x86 algorithm)
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5233
  *
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5234
  * Ouput:
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5235
  *       rax   - int crc result
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5236
  */
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5237
  address generate_updateBytesCRC32C(bool is_pclmulqdq_supported) {
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5238
      assert(UseCRC32CIntrinsics, "need SSE4_2");
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5239
      __ align(CodeEntryAlignment);
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5240
      StubCodeMark mark(this, "StubRoutines", "updateBytesCRC32C");
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5241
      address start = __ pc();
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5242
      //reg.arg        int#0        int#1        int#2        int#3        int#4        int#5        float regs
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5243
      //Windows        RCX          RDX          R8           R9           none         none         XMM0..XMM3
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5244
      //Lin / Sol      RDI          RSI          RDX          RCX          R8           R9           XMM0..XMM7
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5245
      const Register crc = c_rarg0;  // crc
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5246
      const Register buf = c_rarg1;  // source java byte array address
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5247
      const Register len = c_rarg2;  // length
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5248
      const Register a = rax;
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5249
      const Register j = r9;
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5250
      const Register k = r10;
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5251
      const Register l = r11;
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5252
#ifdef _WIN64
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5253
      const Register y = rdi;
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5254
      const Register z = rsi;
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5255
#else
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5256
      const Register y = rcx;
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5257
      const Register z = r8;
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5258
#endif
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5259
      assert_different_registers(crc, buf, len, a, j, k, l, y, z);
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5260
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5261
      BLOCK_COMMENT("Entry:");
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5262
      __ enter(); // required for proper stackwalking of RuntimeStub frame
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5263
#ifdef _WIN64
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5264
      __ push(y);
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5265
      __ push(z);
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5266
#endif
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5267
      __ crc32c_ipl_alg2_alt2(crc, buf, len,
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5268
                              a, j, k,
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5269
                              l, y, z,
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5270
                              c_farg0, c_farg1, c_farg2,
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5271
                              is_pclmulqdq_supported);
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5272
      __ movl(rax, crc);
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5273
#ifdef _WIN64
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5274
      __ pop(z);
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5275
      __ pop(y);
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5276
#endif
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  5277
      __ vzeroupper();
33066
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5278
      __ leave(); // required for proper stackwalking of RuntimeStub frame
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5279
      __ ret(0);
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5280
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5281
      return start;
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5282
  }
26434
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5283
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5284
  /**
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5285
   *  Arguments:
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5286
   *
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5287
   *  Input:
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5288
   *    c_rarg0   - x address
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5289
   *    c_rarg1   - x length
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5290
   *    c_rarg2   - y address
49368
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 49347
diff changeset
  5291
   *    c_rarg3   - y length
26434
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5292
   * not Win64
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5293
   *    c_rarg4   - z address
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5294
   *    c_rarg5   - z length
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5295
   * Win64
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5296
   *    rsp+40    - z address
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5297
   *    rsp+48    - z length
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5298
   */
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5299
  address generate_multiplyToLen() {
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5300
    __ align(CodeEntryAlignment);
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5301
    StubCodeMark mark(this, "StubRoutines", "multiplyToLen");
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5302
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5303
    address start = __ pc();
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5304
    // Win64: rcx, rdx, r8, r9 (c_rarg0, c_rarg1, ...)
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5305
    // Unix:  rdi, rsi, rdx, rcx, r8, r9 (c_rarg0, c_rarg1, ...)
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5306
    const Register x     = rdi;
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5307
    const Register xlen  = rax;
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5308
    const Register y     = rsi;
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5309
    const Register ylen  = rcx;
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5310
    const Register z     = r8;
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5311
    const Register zlen  = r11;
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5312
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5313
    // Next registers will be saved on stack in multiply_to_len().
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5314
    const Register tmp1  = r12;
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5315
    const Register tmp2  = r13;
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5316
    const Register tmp3  = r14;
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5317
    const Register tmp4  = r15;
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5318
    const Register tmp5  = rbx;
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5319
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5320
    BLOCK_COMMENT("Entry:");
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5321
    __ enter(); // required for proper stackwalking of RuntimeStub frame
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5322
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5323
#ifndef _WIN64
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5324
    __ movptr(zlen, r9); // Save r9 in r11 - zlen
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5325
#endif
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5326
    setup_arg_regs(4); // x => rdi, xlen => rsi, y => rdx
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5327
                       // ylen => rcx, z => r8, zlen => r11
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5328
                       // r9 and r10 may be used to save non-volatile registers
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5329
#ifdef _WIN64
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5330
    // last 2 arguments (#4, #5) are on stack on Win64
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5331
    __ movptr(z, Address(rsp, 6 * wordSize));
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5332
    __ movptr(zlen, Address(rsp, 7 * wordSize));
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5333
#endif
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5334
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5335
    __ movptr(xlen, rsi);
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5336
    __ movptr(y,    rdx);
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5337
    __ multiply_to_len(x, xlen, y, ylen, z, zlen, tmp1, tmp2, tmp3, tmp4, tmp5);
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5338
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5339
    restore_arg_regs();
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5340
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5341
    __ leave(); // required for proper stackwalking of RuntimeStub frame
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5342
    __ ret(0);
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5343
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5344
    return start;
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5345
  }
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  5346
35110
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5347
  /**
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5348
  *  Arguments:
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5349
  *
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5350
  *  Input:
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5351
  *    c_rarg0   - obja     address
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5352
  *    c_rarg1   - objb     address
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5353
  *    c_rarg3   - length   length
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5354
  *    c_rarg4   - scale    log2_array_indxscale
38238
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38135
diff changeset
  5355
  *
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38135
diff changeset
  5356
  *  Output:
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38135
diff changeset
  5357
  *        rax   - int >= mismatched index, < 0 bitwise complement of tail
35110
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5358
  */
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5359
  address generate_vectorizedMismatch() {
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5360
    __ align(CodeEntryAlignment);
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5361
    StubCodeMark mark(this, "StubRoutines", "vectorizedMismatch");
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5362
    address start = __ pc();
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5363
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5364
    BLOCK_COMMENT("Entry:");
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5365
    __ enter();
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5366
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5367
#ifdef _WIN64  // Win64: rcx, rdx, r8, r9 (c_rarg0, c_rarg1, ...)
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5368
    const Register scale = c_rarg0;  //rcx, will exchange with r9
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5369
    const Register objb = c_rarg1;   //rdx
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5370
    const Register length = c_rarg2; //r8
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5371
    const Register obja = c_rarg3;   //r9
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5372
    __ xchgq(obja, scale);  //now obja and scale contains the correct contents
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5373
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5374
    const Register tmp1 = r10;
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5375
    const Register tmp2 = r11;
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5376
#endif
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5377
#ifndef _WIN64 // Unix:  rdi, rsi, rdx, rcx, r8, r9 (c_rarg0, c_rarg1, ...)
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5378
    const Register obja = c_rarg0;   //U:rdi
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5379
    const Register objb = c_rarg1;   //U:rsi
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5380
    const Register length = c_rarg2; //U:rdx
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5381
    const Register scale = c_rarg3;  //U:rcx
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5382
    const Register tmp1 = r8;
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5383
    const Register tmp2 = r9;
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5384
#endif
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5385
    const Register result = rax; //return value
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5386
    const XMMRegister vec0 = xmm0;
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5387
    const XMMRegister vec1 = xmm1;
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5388
    const XMMRegister vec2 = xmm2;
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5389
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5390
    __ vectorized_mismatch(obja, objb, length, scale, result, tmp1, tmp2, vec0, vec1, vec2);
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5391
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  5392
    __ vzeroupper();
35110
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5393
    __ leave();
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5394
    __ ret(0);
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5395
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5396
    return start;
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5397
  }
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 34203
diff changeset
  5398
31129
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5399
/**
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5400
   *  Arguments:
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5401
   *
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5402
  //  Input:
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5403
  //    c_rarg0   - x address
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5404
  //    c_rarg1   - x length
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5405
  //    c_rarg2   - z address
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5406
  //    c_rarg3   - z lenth
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5407
   *
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5408
   */
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5409
  address generate_squareToLen() {
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5410
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5411
    __ align(CodeEntryAlignment);
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5412
    StubCodeMark mark(this, "StubRoutines", "squareToLen");
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5413
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5414
    address start = __ pc();
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5415
    // Win64: rcx, rdx, r8, r9 (c_rarg0, c_rarg1, ...)
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5416
    // Unix:  rdi, rsi, rdx, rcx (c_rarg0, c_rarg1, ...)
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5417
    const Register x      = rdi;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5418
    const Register len    = rsi;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5419
    const Register z      = r8;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5420
    const Register zlen   = rcx;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5421
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5422
   const Register tmp1      = r12;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5423
   const Register tmp2      = r13;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5424
   const Register tmp3      = r14;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5425
   const Register tmp4      = r15;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5426
   const Register tmp5      = rbx;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5427
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5428
    BLOCK_COMMENT("Entry:");
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5429
    __ enter(); // required for proper stackwalking of RuntimeStub frame
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5430
51784
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  5431
    setup_arg_regs(4); // x => rdi, len => rsi, z => rdx
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  5432
                       // zlen => rcx
fbec908e2783 8203466: intermittent crash at jdk.internal.misc.Unsafe::getObjectVolatile (native)
coleenp
parents: 51756
diff changeset
  5433
                       // r9 and r10 may be used to save non-volatile registers
31129
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5434
    __ movptr(r8, rdx);
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5435
    __ square_to_len(x, len, z, zlen, tmp1, tmp2, tmp3, tmp4, tmp5, rdx, rax);
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5436
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5437
    restore_arg_regs();
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5438
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5439
    __ leave(); // required for proper stackwalking of RuntimeStub frame
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5440
    __ ret(0);
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5441
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5442
    return start;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5443
  }
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5444
52142
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5445
  address generate_method_entry_barrier() {
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5446
    __ align(CodeEntryAlignment);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5447
    StubCodeMark mark(this, "StubRoutines", "nmethod_entry_barrier");
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5448
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5449
    Label deoptimize_label;
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5450
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5451
    address start = __ pc();
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5452
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5453
    __ push(-1); // cookie, this is used for writing the new rsp when deoptimizing
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5454
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5455
    BLOCK_COMMENT("Entry:");
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5456
    __ enter(); // save rbp
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5457
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5458
    // save c_rarg0, because we want to use that value.
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5459
    // We could do without it but then we depend on the number of slots used by pusha
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5460
    __ push(c_rarg0);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5461
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5462
    __ lea(c_rarg0, Address(rsp, wordSize * 3)); // 1 for cookie, 1 for rbp, 1 for c_rarg0 - this should be the return address
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5463
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5464
    __ pusha();
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5465
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5466
    // The method may have floats as arguments, and we must spill them before calling
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5467
    // the VM runtime.
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5468
    assert(Argument::n_float_register_parameters_j == 8, "Assumption");
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5469
    const int xmm_size = wordSize * 2;
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5470
    const int xmm_spill_size = xmm_size * Argument::n_float_register_parameters_j;
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5471
    __ subptr(rsp, xmm_spill_size);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5472
    __ movdqu(Address(rsp, xmm_size * 7), xmm7);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5473
    __ movdqu(Address(rsp, xmm_size * 6), xmm6);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5474
    __ movdqu(Address(rsp, xmm_size * 5), xmm5);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5475
    __ movdqu(Address(rsp, xmm_size * 4), xmm4);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5476
    __ movdqu(Address(rsp, xmm_size * 3), xmm3);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5477
    __ movdqu(Address(rsp, xmm_size * 2), xmm2);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5478
    __ movdqu(Address(rsp, xmm_size * 1), xmm1);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5479
    __ movdqu(Address(rsp, xmm_size * 0), xmm0);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5480
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5481
    __ call_VM_leaf(CAST_FROM_FN_PTR(address, static_cast<int (*)(address*)>(BarrierSetNMethod::nmethod_stub_entry_barrier)), 1);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5482
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5483
    __ movdqu(xmm0, Address(rsp, xmm_size * 0));
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5484
    __ movdqu(xmm1, Address(rsp, xmm_size * 1));
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5485
    __ movdqu(xmm2, Address(rsp, xmm_size * 2));
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5486
    __ movdqu(xmm3, Address(rsp, xmm_size * 3));
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5487
    __ movdqu(xmm4, Address(rsp, xmm_size * 4));
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5488
    __ movdqu(xmm5, Address(rsp, xmm_size * 5));
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5489
    __ movdqu(xmm6, Address(rsp, xmm_size * 6));
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5490
    __ movdqu(xmm7, Address(rsp, xmm_size * 7));
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5491
    __ addptr(rsp, xmm_spill_size);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5492
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5493
    __ cmpl(rax, 1); // 1 means deoptimize
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5494
    __ jcc(Assembler::equal, deoptimize_label);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5495
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5496
    __ popa();
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5497
    __ pop(c_rarg0);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5498
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5499
    __ leave();
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5500
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5501
    __ addptr(rsp, 1 * wordSize); // cookie
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5502
    __ ret(0);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5503
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5504
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5505
    __ BIND(deoptimize_label);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5506
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5507
    __ popa();
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5508
    __ pop(c_rarg0);
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5509
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5510
    __ leave();
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5511
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5512
    // this can be taken out, but is good for verification purposes. getting a SIGSEGV
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5513
    // here while still having a correct stack is valuable
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5514
    __ testptr(rsp, Address(rsp, 0));
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5515
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5516
    __ movptr(rsp, Address(rsp, 0)); // new rsp was written in the barrier
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5517
    __ jmp(Address(rsp, -1 * wordSize)); // jmp target should be callers verified_entry_point
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5518
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5519
    return start;
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5520
  }
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  5521
31129
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5522
   /**
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5523
   *  Arguments:
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5524
   *
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5525
   *  Input:
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5526
   *    c_rarg0   - out address
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5527
   *    c_rarg1   - in address
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5528
   *    c_rarg2   - offset
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5529
   *    c_rarg3   - len
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5530
   * not Win64
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5531
   *    c_rarg4   - k
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5532
   * Win64
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5533
   *    rsp+40    - k
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5534
   */
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5535
  address generate_mulAdd() {
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5536
    __ align(CodeEntryAlignment);
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5537
    StubCodeMark mark(this, "StubRoutines", "mulAdd");
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5538
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5539
    address start = __ pc();
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5540
    // Win64: rcx, rdx, r8, r9 (c_rarg0, c_rarg1, ...)
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5541
    // Unix:  rdi, rsi, rdx, rcx, r8, r9 (c_rarg0, c_rarg1, ...)
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5542
    const Register out     = rdi;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5543
    const Register in      = rsi;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5544
    const Register offset  = r11;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5545
    const Register len     = rcx;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5546
    const Register k       = r8;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5547
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5548
    // Next registers will be saved on stack in mul_add().
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5549
    const Register tmp1  = r12;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5550
    const Register tmp2  = r13;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5551
    const Register tmp3  = r14;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5552
    const Register tmp4  = r15;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5553
    const Register tmp5  = rbx;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5554
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5555
    BLOCK_COMMENT("Entry:");
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5556
    __ enter(); // required for proper stackwalking of RuntimeStub frame
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5557
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5558
    setup_arg_regs(4); // out => rdi, in => rsi, offset => rdx
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5559
                       // len => rcx, k => r8
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5560
                       // r9 and r10 may be used to save non-volatile registers
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5561
#ifdef _WIN64
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5562
    // last argument is on stack on Win64
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5563
    __ movl(k, Address(rsp, 6 * wordSize));
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5564
#endif
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5565
    __ movptr(r11, rdx);  // move offset in rdx to offset(r11)
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5566
    __ mul_add(out, in, offset, len, k, tmp1, tmp2, tmp3, tmp4, tmp5, rdx, rax);
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5567
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5568
    restore_arg_regs();
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5569
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5570
    __ leave(); // required for proper stackwalking of RuntimeStub frame
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5571
    __ ret(0);
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5572
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5573
    return start;
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5574
  }
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5575
33089
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5576
  address generate_libmExp() {
47810
083c15bfba35 8190887: Stub code marking missing from some x86 generated stub routines
psandoz
parents: 47634
diff changeset
  5577
    StubCodeMark mark(this, "StubRoutines", "libmExp");
083c15bfba35 8190887: Stub code marking missing from some x86 generated stub routines
psandoz
parents: 47634
diff changeset
  5578
33089
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5579
    address start = __ pc();
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5580
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5581
    const XMMRegister x0  = xmm0;
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5582
    const XMMRegister x1  = xmm1;
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5583
    const XMMRegister x2  = xmm2;
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5584
    const XMMRegister x3  = xmm3;
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5585
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5586
    const XMMRegister x4  = xmm4;
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5587
    const XMMRegister x5  = xmm5;
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5588
    const XMMRegister x6  = xmm6;
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5589
    const XMMRegister x7  = xmm7;
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5590
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5591
    const Register tmp   = r11;
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5592
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5593
    BLOCK_COMMENT("Entry:");
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5594
    __ enter(); // required for proper stackwalking of RuntimeStub frame
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5595
46440
61025eecb743 8178811: Minimize the AVX <-> SSE transition penalty through generation of vzeroupper instruction on x86
vdeshpande
parents: 43423
diff changeset
  5596
    __ fast_exp(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp);
33089
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5597
33465
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5598
    __ leave(); // required for proper stackwalking of RuntimeStub frame
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5599
    __ ret(0);
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5600
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5601
    return start;
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5602
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5603
  }
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5604
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5605
  address generate_libmLog() {
47810
083c15bfba35 8190887: Stub code marking missing from some x86 generated stub routines
psandoz
parents: 47634
diff changeset
  5606
    StubCodeMark mark(this, "StubRoutines", "libmLog");
083c15bfba35 8190887: Stub code marking missing from some x86 generated stub routines
psandoz
parents: 47634
diff changeset
  5607
33465
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5608
    address start = __ pc();
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5609
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5610
    const XMMRegister x0 = xmm0;
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5611
    const XMMRegister x1 = xmm1;
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5612
    const XMMRegister x2 = xmm2;
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5613
    const XMMRegister x3 = xmm3;
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5614
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5615
    const XMMRegister x4 = xmm4;
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5616
    const XMMRegister x5 = xmm5;
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5617
    const XMMRegister x6 = xmm6;
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5618
    const XMMRegister x7 = xmm7;
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5619
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5620
    const Register tmp1 = r11;
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5621
    const Register tmp2 = r8;
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5622
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5623
    BLOCK_COMMENT("Entry:");
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5624
    __ enter(); // required for proper stackwalking of RuntimeStub frame
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5625
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5626
    __ fast_log(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2);
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  5627
33089
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5628
    __ leave(); // required for proper stackwalking of RuntimeStub frame
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5629
    __ ret(0);
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5630
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5631
    return start;
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5632
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5633
  }
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 33066
diff changeset
  5634
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5635
  address generate_libmLog10() {
47810
083c15bfba35 8190887: Stub code marking missing from some x86 generated stub routines
psandoz
parents: 47634
diff changeset
  5636
    StubCodeMark mark(this, "StubRoutines", "libmLog10");
083c15bfba35 8190887: Stub code marking missing from some x86 generated stub routines
psandoz
parents: 47634
diff changeset
  5637
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5638
    address start = __ pc();
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5639
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5640
    const XMMRegister x0 = xmm0;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5641
    const XMMRegister x1 = xmm1;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5642
    const XMMRegister x2 = xmm2;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5643
    const XMMRegister x3 = xmm3;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5644
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5645
    const XMMRegister x4 = xmm4;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5646
    const XMMRegister x5 = xmm5;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5647
    const XMMRegister x6 = xmm6;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5648
    const XMMRegister x7 = xmm7;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5649
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5650
    const Register tmp = r11;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5651
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5652
    BLOCK_COMMENT("Entry:");
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5653
    __ enter(); // required for proper stackwalking of RuntimeStub frame
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5654
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5655
    __ fast_log10(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp);
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5656
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5657
    __ leave(); // required for proper stackwalking of RuntimeStub frame
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5658
    __ ret(0);
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5659
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5660
    return start;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5661
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5662
  }
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5663
35146
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5664
  address generate_libmPow() {
47810
083c15bfba35 8190887: Stub code marking missing from some x86 generated stub routines
psandoz
parents: 47634
diff changeset
  5665
    StubCodeMark mark(this, "StubRoutines", "libmPow");
083c15bfba35 8190887: Stub code marking missing from some x86 generated stub routines
psandoz
parents: 47634
diff changeset
  5666
35146
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5667
    address start = __ pc();
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5668
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5669
    const XMMRegister x0 = xmm0;
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5670
    const XMMRegister x1 = xmm1;
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5671
    const XMMRegister x2 = xmm2;
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5672
    const XMMRegister x3 = xmm3;
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5673
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5674
    const XMMRegister x4 = xmm4;
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5675
    const XMMRegister x5 = xmm5;
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5676
    const XMMRegister x6 = xmm6;
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5677
    const XMMRegister x7 = xmm7;
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5678
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5679
    const Register tmp1 = r8;
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5680
    const Register tmp2 = r9;
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5681
    const Register tmp3 = r10;
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5682
    const Register tmp4 = r11;
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5683
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5684
    BLOCK_COMMENT("Entry:");
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5685
    __ enter(); // required for proper stackwalking of RuntimeStub frame
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5686
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5687
    __ fast_pow(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2, tmp3, tmp4);
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5688
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5689
    __ leave(); // required for proper stackwalking of RuntimeStub frame
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5690
    __ ret(0);
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5691
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5692
    return start;
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5693
9ebfec283f56 8145688: Update for x86 pow in the math lib
kvn
parents: 35135
diff changeset
  5694
  }
31129
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  5695
35540
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5696
  address generate_libmSin() {
47810
083c15bfba35 8190887: Stub code marking missing from some x86 generated stub routines
psandoz
parents: 47634
diff changeset
  5697
    StubCodeMark mark(this, "StubRoutines", "libmSin");
083c15bfba35 8190887: Stub code marking missing from some x86 generated stub routines
psandoz
parents: 47634
diff changeset
  5698
35540
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5699
    address start = __ pc();
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5700
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5701
    const XMMRegister x0 = xmm0;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5702
    const XMMRegister x1 = xmm1;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5703
    const XMMRegister x2 = xmm2;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5704
    const XMMRegister x3 = xmm3;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5705
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5706
    const XMMRegister x4 = xmm4;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5707
    const XMMRegister x5 = xmm5;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5708
    const XMMRegister x6 = xmm6;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5709
    const XMMRegister x7 = xmm7;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5710
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5711
    const Register tmp1 = r8;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5712
    const Register tmp2 = r9;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5713
    const Register tmp3 = r10;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5714
    const Register tmp4 = r11;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5715
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5716
    BLOCK_COMMENT("Entry:");
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5717
    __ enter(); // required for proper stackwalking of RuntimeStub frame
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5718
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5719
#ifdef _WIN64
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5720
    __ push(rsi);
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5721
    __ push(rdi);
35540
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5722
#endif
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5723
    __ fast_sin(x0, x1, x2, x3, x4, x5, x6, x7, rax, rbx, rcx, rdx, tmp1, tmp2, tmp3, tmp4);
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5724
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5725
#ifdef _WIN64
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5726
    __ pop(rdi);
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5727
    __ pop(rsi);
35540
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5728
#endif
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5729
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5730
    __ leave(); // required for proper stackwalking of RuntimeStub frame
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5731
    __ ret(0);
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5732
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5733
    return start;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5734
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5735
  }
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5736
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5737
  address generate_libmCos() {
47810
083c15bfba35 8190887: Stub code marking missing from some x86 generated stub routines
psandoz
parents: 47634
diff changeset
  5738
    StubCodeMark mark(this, "StubRoutines", "libmCos");
083c15bfba35 8190887: Stub code marking missing from some x86 generated stub routines
psandoz
parents: 47634
diff changeset
  5739
35540
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5740
    address start = __ pc();
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5741
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5742
    const XMMRegister x0 = xmm0;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5743
    const XMMRegister x1 = xmm1;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5744
    const XMMRegister x2 = xmm2;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5745
    const XMMRegister x3 = xmm3;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5746
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5747
    const XMMRegister x4 = xmm4;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5748
    const XMMRegister x5 = xmm5;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5749
    const XMMRegister x6 = xmm6;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5750
    const XMMRegister x7 = xmm7;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5751
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5752
    const Register tmp1 = r8;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5753
    const Register tmp2 = r9;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5754
    const Register tmp3 = r10;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5755
    const Register tmp4 = r11;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5756
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5757
    BLOCK_COMMENT("Entry:");
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5758
    __ enter(); // required for proper stackwalking of RuntimeStub frame
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5759
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5760
#ifdef _WIN64
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5761
    __ push(rsi);
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5762
    __ push(rdi);
35540
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5763
#endif
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5764
    __ fast_cos(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2, tmp3, tmp4);
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5765
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5766
#ifdef _WIN64
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5767
    __ pop(rdi);
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5768
    __ pop(rsi);
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5769
#endif
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5770
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5771
    __ leave(); // required for proper stackwalking of RuntimeStub frame
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5772
    __ ret(0);
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5773
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5774
    return start;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5775
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5776
  }
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5777
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5778
  address generate_libmTan() {
47810
083c15bfba35 8190887: Stub code marking missing from some x86 generated stub routines
psandoz
parents: 47634
diff changeset
  5779
    StubCodeMark mark(this, "StubRoutines", "libmTan");
083c15bfba35 8190887: Stub code marking missing from some x86 generated stub routines
psandoz
parents: 47634
diff changeset
  5780
38018
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5781
    address start = __ pc();
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5782
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5783
    const XMMRegister x0 = xmm0;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5784
    const XMMRegister x1 = xmm1;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5785
    const XMMRegister x2 = xmm2;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5786
    const XMMRegister x3 = xmm3;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5787
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5788
    const XMMRegister x4 = xmm4;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5789
    const XMMRegister x5 = xmm5;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5790
    const XMMRegister x6 = xmm6;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5791
    const XMMRegister x7 = xmm7;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5792
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5793
    const Register tmp1 = r8;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5794
    const Register tmp2 = r9;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5795
    const Register tmp3 = r10;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5796
    const Register tmp4 = r11;
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5797
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5798
    BLOCK_COMMENT("Entry:");
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5799
    __ enter(); // required for proper stackwalking of RuntimeStub frame
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5800
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5801
#ifdef _WIN64
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5802
    __ push(rsi);
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5803
    __ push(rdi);
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5804
#endif
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5805
    __ fast_tan(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2, tmp3, tmp4);
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5806
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5807
#ifdef _WIN64
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5808
    __ pop(rdi);
1dc6c6f21231 8152907: Update for x86 tan and log10 in the math lib
vdeshpande
parents: 36825
diff changeset
  5809
    __ pop(rsi);
35540
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5810
#endif
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5811
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5812
    __ leave(); // required for proper stackwalking of RuntimeStub frame
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5813
    __ ret(0);
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5814
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5815
    return start;
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5816
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5817
  }
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35537
diff changeset
  5818
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5819
#undef __
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5820
#define __ masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5821
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5822
  // Continuation point for throwing of implicit exceptions that are
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5823
  // not handled in the current activation. Fabricates an exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5824
  // oop and initiates normal exception dispatching in this
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5825
  // frame. Since we need to preserve callee-saved values (currently
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5826
  // only for C2, but done for C1 as well) we need a callee-saved oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5827
  // map and therefore have to make these stubs into RuntimeStubs
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5828
  // rather than BufferBlobs.  If the compiler needs all registers to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5829
  // be preserved between the fault point and the exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5830
  // then it must assume responsibility for that in
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5831
  // AbstractCompiler::continuation_for_implicit_null_exception or
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5832
  // continuation_for_implicit_division_by_zero_exception. All other
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5833
  // implicit exceptions (e.g., NullPointerException or
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5834
  // AbstractMethodError on entry) are either at call sites or
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5835
  // otherwise assume that stack unwinding will be initiated, so
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5836
  // caller saved registers were assumed volatile in the compiler.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5837
  address generate_throw_exception(const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5838
                                   address runtime_entry,
10004
190e88f7edd1 7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents: 8876
diff changeset
  5839
                                   Register arg1 = noreg,
190e88f7edd1 7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents: 8876
diff changeset
  5840
                                   Register arg2 = noreg) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5841
    // Information about frame layout at time of blocking runtime call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5842
    // Note that we only have to preserve callee-saved registers since
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5843
    // the compilers are responsible for supplying a continuation point
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5844
    // if they expect all registers to be preserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5845
    enum layout {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5846
      rbp_off = frame::arg_reg_save_area_bytes/BytesPerInt,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5847
      rbp_off2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5848
      return_off,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5849
      return_off2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5850
      framesize // inclusive of return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5851
    };
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5852
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5853
    int insts_size = 512;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5854
    int locs_size  = 64;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5855
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5856
    CodeBuffer code(name, insts_size, locs_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5857
    OopMapSet* oop_maps  = new OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5858
    MacroAssembler* masm = new MacroAssembler(&code);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5859
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5860
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5861
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5862
    // This is an inlined and slightly modified version of call_VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5863
    // which has the ability to fetch the return PC out of
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5864
    // thread-local storage and also sets up last_Java_sp slightly
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5865
    // differently than the real call_VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5866
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5867
    __ enter(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5868
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5869
    assert(is_even(framesize/2), "sp not 16-byte aligned");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5870
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5871
    // return address and rbp are already in place
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  5872
    __ subptr(rsp, (framesize-4) << LogBytesPerInt); // prolog
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5873
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5874
    int frame_complete = __ pc() - start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5875
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5876
    // Set up last_Java_sp and last_Java_fp
11725
49d1e1f1421f 7119286: JSR292: SIGSEGV in JNIHandleBlock::release_block(JNIHandleBlock*, Thread*)+0x3c
roland
parents: 11439
diff changeset
  5877
    address the_pc = __ pc();
49d1e1f1421f 7119286: JSR292: SIGSEGV in JNIHandleBlock::release_block(JNIHandleBlock*, Thread*)+0x3c
roland
parents: 11439
diff changeset
  5878
    __ set_last_Java_frame(rsp, rbp, the_pc);
49d1e1f1421f 7119286: JSR292: SIGSEGV in JNIHandleBlock::release_block(JNIHandleBlock*, Thread*)+0x3c
roland
parents: 11439
diff changeset
  5879
    __ andptr(rsp, -(StackAlignmentInBytes));    // Align stack
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5880
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5881
    // Call runtime
10004
190e88f7edd1 7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents: 8876
diff changeset
  5882
    if (arg1 != noreg) {
190e88f7edd1 7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents: 8876
diff changeset
  5883
      assert(arg2 != c_rarg1, "clobbered");
190e88f7edd1 7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents: 8876
diff changeset
  5884
      __ movptr(c_rarg1, arg1);
190e88f7edd1 7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents: 8876
diff changeset
  5885
    }
190e88f7edd1 7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents: 8876
diff changeset
  5886
    if (arg2 != noreg) {
190e88f7edd1 7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents: 8876
diff changeset
  5887
      __ movptr(c_rarg2, arg2);
190e88f7edd1 7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents: 8876
diff changeset
  5888
    }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  5889
    __ movptr(c_rarg0, r15_thread);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5890
    BLOCK_COMMENT("call runtime_entry");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5891
    __ call(RuntimeAddress(runtime_entry));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5892
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5893
    // Generate oop map
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5894
    OopMap* map = new OopMap(framesize, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5895
11785
10f778832544 7144405: JumbleGC002 assert(m->offset() == pc_offset) failed: oopmap not found
roland
parents: 11725
diff changeset
  5896
    oop_maps->add_gc_map(the_pc - start, map);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5897
40644
39e631ed7145 8161598: Kitchensink fails: assert(nm->insts_contains(original_pc)) failed: original PC must be in nmethod/CompiledMethod
dlong
parents: 38699
diff changeset
  5898
    __ reset_last_Java_frame(true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5899
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5900
    __ leave(); // required for proper stackwalking of RuntimeStub frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5901
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5902
    // check for pending exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5903
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5904
    Label L;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  5905
    __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()),
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  5906
            (int32_t) NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5907
    __ jcc(Assembler::notEqual, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5908
    __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5909
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5910
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5911
    __ jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5912
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5913
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5914
    // codeBlob framesize is in words (not VMRegImpl::slot_size)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5915
    RuntimeStub* stub =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5916
      RuntimeStub::new_runtime_stub(name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5917
                                    &code,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5918
                                    frame_complete,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5919
                                    (framesize >> (LogBytesPerWord - LogBytesPerInt)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5920
                                    oop_maps, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5921
    return stub->entry_point();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5922
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5923
18958
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5924
  void create_control_words() {
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5925
    // Round to nearest, 53-bit mode, exceptions masked
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5926
    StubRoutines::_fpu_cntrl_wrd_std   = 0x027F;
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5927
    // Round to zero, 53-bit mode, exception mased
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5928
    StubRoutines::_fpu_cntrl_wrd_trunc = 0x0D7F;
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5929
    // Round to nearest, 24-bit mode, exceptions masked
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5930
    StubRoutines::_fpu_cntrl_wrd_24    = 0x007F;
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5931
    // Round to nearest, 64-bit mode, exceptions masked
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5932
    StubRoutines::_mxcsr_std           = 0x1F80;
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5933
    // Note: the following two constants are 80-bit values
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5934
    //       layout is critical for correct loading by FPU.
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5935
    // Bias for strict fp multiply/divide
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5936
    StubRoutines::_fpu_subnormal_bias1[0]= 0x00000000; // 2^(-15360) == 0x03ff 8000 0000 0000 0000
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5937
    StubRoutines::_fpu_subnormal_bias1[1]= 0x80000000;
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5938
    StubRoutines::_fpu_subnormal_bias1[2]= 0x03ff;
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5939
    // Un-Bias for strict fp multiply/divide
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5940
    StubRoutines::_fpu_subnormal_bias2[0]= 0x00000000; // 2^(+15360) == 0x7bff 8000 0000 0000 0000
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5941
    StubRoutines::_fpu_subnormal_bias2[1]= 0x80000000;
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5942
    StubRoutines::_fpu_subnormal_bias2[2]= 0x7bff;
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5943
  }
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5944
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5945
  // Initialization
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5946
  void generate_initial() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5947
    // Generates all stubs and initializes the entry points
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5948
18958
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5949
    // This platform-specific settings are needed by generate_call_stub()
7fdf6d23667d 8020433: Crash when using -XX:+RestoreMXCSROnJNICalls
kvn
parents: 18507
diff changeset
  5950
    create_control_words();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5951
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5952
    // entry points that exist in all platforms Note: This is code
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5953
    // that could be shared among different platforms - however the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5954
    // benefit seems to be smaller than the disadvantage of having a
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5955
    // much more complicated generator structure. See also comment in
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5956
    // stubRoutines.hpp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5957
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5958
    StubRoutines::_forward_exception_entry = generate_forward_exception();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5959
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5960
    StubRoutines::_call_stub_entry =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5961
      generate_call_stub(StubRoutines::_call_stub_return_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5962
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5963
    // is referenced by megamorphic call
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5964
    StubRoutines::_catch_exception_entry = generate_catch_exception();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5965
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5966
    // atomic calls
48468
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
  5967
    StubRoutines::_atomic_xchg_entry          = generate_atomic_xchg();
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
  5968
    StubRoutines::_atomic_xchg_long_entry     = generate_atomic_xchg_long();
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
  5969
    StubRoutines::_atomic_cmpxchg_entry       = generate_atomic_cmpxchg();
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
  5970
    StubRoutines::_atomic_cmpxchg_byte_entry  = generate_atomic_cmpxchg_byte();
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
  5971
    StubRoutines::_atomic_cmpxchg_long_entry  = generate_atomic_cmpxchg_long();
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
  5972
    StubRoutines::_atomic_add_entry           = generate_atomic_add();
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
  5973
    StubRoutines::_atomic_add_long_entry      = generate_atomic_add_long();
7cc7de9bf4a4 8186903: Remove j-types from Atomic
coleenp
parents: 48104
diff changeset
  5974
    StubRoutines::_fence_entry                = generate_orderaccess_fence();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5975
489c9b5090e2 Initial load
duke
parents:
diff changeset
  5976
    // platform dependent
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  5977
    StubRoutines::x86::_get_previous_fp_entry = generate_get_previous_fp();
11961
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 11785
diff changeset
  5978
    StubRoutines::x86::_get_previous_sp_entry = generate_get_previous_sp();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  5979
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  5980
    StubRoutines::x86::_verify_mxcsr_entry    = generate_verify_mxcsr();
10004
190e88f7edd1 7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents: 8876
diff changeset
  5981
11411
16b151e1e088 7116216: StackOverflow GC crash
bdelsart
parents: 11194
diff changeset
  5982
    // Build this early so it's available for the interpreter.
16b151e1e088 7116216: StackOverflow GC crash
bdelsart
parents: 11194
diff changeset
  5983
    StubRoutines::_throw_StackOverflowError_entry =
16b151e1e088 7116216: StackOverflow GC crash
bdelsart
parents: 11194
diff changeset
  5984
      generate_throw_exception("StackOverflowError throw_exception",
16b151e1e088 7116216: StackOverflow GC crash
bdelsart
parents: 11194
diff changeset
  5985
                               CAST_FROM_FN_PTR(address,
16b151e1e088 7116216: StackOverflow GC crash
bdelsart
parents: 11194
diff changeset
  5986
                                                SharedRuntime::
16b151e1e088 7116216: StackOverflow GC crash
bdelsart
parents: 11194
diff changeset
  5987
                                                throw_StackOverflowError));
35071
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34203
diff changeset
  5988
    StubRoutines::_throw_delayed_StackOverflowError_entry =
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34203
diff changeset
  5989
      generate_throw_exception("delayed StackOverflowError throw_exception",
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34203
diff changeset
  5990
                               CAST_FROM_FN_PTR(address,
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34203
diff changeset
  5991
                                                SharedRuntime::
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34203
diff changeset
  5992
                                                throw_delayed_StackOverflowError));
18507
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5993
    if (UseCRC32Intrinsics) {
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5994
      // set table address before stub generation which use it
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5995
      StubRoutines::_crc_table_adr = (address)StubRoutines::x86::_crc_table;
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5996
      StubRoutines::_updateBytesCRC32 = generate_updateBytesCRC32();
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18073
diff changeset
  5997
    }
33066
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5998
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  5999
    if (UseCRC32CIntrinsics) {
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  6000
      bool supports_clmul = VM_Version::supports_clmul();
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  6001
      StubRoutines::x86::generate_CRC32C_table(supports_clmul);
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  6002
      StubRoutines::_crc32c_table_addr = (address)StubRoutines::x86::_crc32c_table;
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  6003
      StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C(supports_clmul);
d98eab8215c4 8134553: CRC32C implementations for x86/x64 targets
kvn
parents: 32727
diff changeset
  6004
    }
42618
08162de8f053 8170430: x86 pow() stub from Intel libm is inconsistent with pow() from fdlib
vdeshpande
parents: 42039
diff changeset
  6005
    if (VM_Version::supports_sse2() && UseLibmIntrinsic && InlineIntrinsics) {
38699
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6006
      if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dsin) ||
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6007
          vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dcos) ||
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6008
          vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dtan)) {
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6009
        StubRoutines::x86::_ONEHALF_adr = (address)StubRoutines::x86::_ONEHALF;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6010
        StubRoutines::x86::_P_2_adr = (address)StubRoutines::x86::_P_2;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6011
        StubRoutines::x86::_SC_4_adr = (address)StubRoutines::x86::_SC_4;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6012
        StubRoutines::x86::_Ctable_adr = (address)StubRoutines::x86::_Ctable;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6013
        StubRoutines::x86::_SC_2_adr = (address)StubRoutines::x86::_SC_2;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6014
        StubRoutines::x86::_SC_3_adr = (address)StubRoutines::x86::_SC_3;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6015
        StubRoutines::x86::_SC_1_adr = (address)StubRoutines::x86::_SC_1;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6016
        StubRoutines::x86::_PI_INV_TABLE_adr = (address)StubRoutines::x86::_PI_INV_TABLE;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6017
        StubRoutines::x86::_PI_4_adr = (address)StubRoutines::x86::_PI_4;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6018
        StubRoutines::x86::_PI32INV_adr = (address)StubRoutines::x86::_PI32INV;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6019
        StubRoutines::x86::_SIGN_MASK_adr = (address)StubRoutines::x86::_SIGN_MASK;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6020
        StubRoutines::x86::_P_1_adr = (address)StubRoutines::x86::_P_1;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6021
        StubRoutines::x86::_P_3_adr = (address)StubRoutines::x86::_P_3;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6022
        StubRoutines::x86::_NEG_ZERO_adr = (address)StubRoutines::x86::_NEG_ZERO;
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6023
      }
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6024
      if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dexp)) {
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6025
        StubRoutines::_dexp = generate_libmExp();
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6026
      }
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6027
      if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dlog)) {
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6028
        StubRoutines::_dlog = generate_libmLog();
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6029
      }
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6030
      if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dlog10)) {
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6031
        StubRoutines::_dlog10 = generate_libmLog10();
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6032
      }
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6033
      if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dpow)) {
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6034
        StubRoutines::_dpow = generate_libmPow();
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6035
      }
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6036
      if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dsin)) {
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6037
        StubRoutines::_dsin = generate_libmSin();
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6038
      }
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6039
      if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dcos)) {
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6040
        StubRoutines::_dcos = generate_libmCos();
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6041
      }
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6042
      if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dtan)) {
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6043
        StubRoutines::_dtan = generate_libmTan();
f8bec5f6b09c 8154473: Update for CompilerDirectives to control stub generation and intrinsics
vdeshpande
parents: 38246
diff changeset
  6044
      }
33465
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
  6045
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6046
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6047
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6048
  void generate_all() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6049
    // Generates all stubs and initializes the entry points
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6050
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6051
    // These entry points require SharedInfo::stack0 to be set up in
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6052
    // non-core builds and need to be relocatable, so they each
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6053
    // fabricate a RuntimeStub internally.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6054
    StubRoutines::_throw_AbstractMethodError_entry =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6055
      generate_throw_exception("AbstractMethodError throw_exception",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6056
                               CAST_FROM_FN_PTR(address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6057
                                                SharedRuntime::
10545
fec876499aae 7088020: SEGV in JNIHandleBlock::release_block
never
parents: 10004
diff changeset
  6058
                                                throw_AbstractMethodError));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6059
189
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
  6060
    StubRoutines::_throw_IncompatibleClassChangeError_entry =
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
  6061
      generate_throw_exception("IncompatibleClassChangeError throw_exception",
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
  6062
                               CAST_FROM_FN_PTR(address,
4248c8e21063 6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents: 1
diff changeset
  6063
                                                SharedRuntime::
10545
fec876499aae 7088020: SEGV in JNIHandleBlock::release_block
never
parents: 10004
diff changeset
  6064
                                                throw_IncompatibleClassChangeError));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6065
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6066
    StubRoutines::_throw_NullPointerException_at_call_entry =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6067
      generate_throw_exception("NullPointerException at call throw_exception",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6068
                               CAST_FROM_FN_PTR(address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6069
                                                SharedRuntime::
10545
fec876499aae 7088020: SEGV in JNIHandleBlock::release_block
never
parents: 10004
diff changeset
  6070
                                                throw_NullPointerException_at_call));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6071
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6072
    // entry points that are platform specific
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  6073
    StubRoutines::x86::_f2i_fixup = generate_f2i_fixup();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  6074
    StubRoutines::x86::_f2l_fixup = generate_f2l_fixup();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  6075
    StubRoutines::x86::_d2i_fixup = generate_d2i_fixup();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  6076
    StubRoutines::x86::_d2l_fixup = generate_d2l_fixup();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  6077
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  6078
    StubRoutines::x86::_float_sign_mask  = generate_fp_mask("float_sign_mask",  0x7FFFFFFF7FFFFFFF);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  6079
    StubRoutines::x86::_float_sign_flip  = generate_fp_mask("float_sign_flip",  0x8000000080000000);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  6080
    StubRoutines::x86::_double_sign_mask = generate_fp_mask("double_sign_mask", 0x7FFFFFFFFFFFFFFF);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 957
diff changeset
  6081
    StubRoutines::x86::_double_sign_flip = generate_fp_mask("double_sign_flip", 0x8000000000000000);
54750
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  6082
    StubRoutines::x86::_vector_float_sign_mask = generate_vector_mask("vector_float_sign_mask", 0x7FFFFFFF7FFFFFFF);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  6083
    StubRoutines::x86::_vector_float_sign_flip = generate_vector_mask("vector_float_sign_flip", 0x8000000080000000);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  6084
    StubRoutines::x86::_vector_double_sign_mask = generate_vector_mask("vector_double_sign_mask", 0x7FFFFFFFFFFFFFFF);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  6085
    StubRoutines::x86::_vector_double_sign_flip = generate_vector_mask("vector_double_sign_flip", 0x8000000000000000);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  6086
    StubRoutines::x86::_vector_short_to_byte_mask = generate_vector_mask("vector_short_to_byte_mask", 0x00ff00ff00ff00ff);
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  6087
    StubRoutines::x86::_vector_byte_perm_mask = generate_vector_byte_perm_mask("vector_byte_perm_mask");
1851a532ddfe 8222074: Enhance auto vectorization for x86
sviswanathan
parents: 53546
diff changeset
  6088
    StubRoutines::x86::_vector_long_sign_mask = generate_vector_mask("vector_long_sign_mask", 0x8000000000000000);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6089
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6090
    // support for verify_oop (must happen after universe_init)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6091
    StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6092
57804
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  6093
    // data cache line writeback
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  6094
    StubRoutines::_data_cache_writeback = generate_data_cache_writeback();
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  6095
    StubRoutines::_data_cache_writeback_sync = generate_data_cache_writeback_sync();
9b7b9f16dfd9 8224974: Implement JEP 352
adinn
parents: 57786
diff changeset
  6096
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6097
    // arraycopy stubs used by compilers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6098
    generate_arraycopy_stubs();
4478
c3a8af0fc6b0 6829192: JSR 292 needs to support 64-bit x86
twisti
parents: 3262
diff changeset
  6099
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  6100
    // don't bother generating these AES intrinsic stubs unless global flag is set
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  6101
    if (UseAESIntrinsics) {
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  6102
      StubRoutines::x86::_key_shuffle_mask_addr = generate_key_shuffle_mask();  // needed by the others
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  6103
      StubRoutines::_aescrypt_encryptBlock = generate_aescrypt_encryptBlock();
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  6104
      StubRoutines::_aescrypt_decryptBlock = generate_aescrypt_decryptBlock();
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  6105
      StubRoutines::_cipherBlockChaining_encryptAESCrypt = generate_cipherBlockChaining_encryptAESCrypt();
50699
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  6106
      if (VM_Version::supports_vaes() &&  VM_Version::supports_avx512vl() && VM_Version::supports_avx512dq() ) {
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  6107
        StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptVectorAESCrypt();
57786
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  6108
        StubRoutines::_electronicCodeBook_encryptAESCrypt = generate_electronicCodeBook_encryptAESCrypt();
948ac3112da8 8225625: AES Electronic Codebook (ECB) encryption and decryption optimization using AVX512 + VAES instructions
srukmannagar
parents: 55490
diff changeset
  6109
        StubRoutines::_electronicCodeBook_decryptAESCrypt = generate_electronicCodeBook_decryptAESCrypt();
50699
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  6110
      } else {
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  6111
        StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt_Parallel();
cc7fc46cc8c1 8205398: AES-CBC decryption algorithm using AVX512 instructions
kvn
parents: 50525
diff changeset
  6112
      }
14132
3c1437abcefd 7184394: add intrinsics to use AES instructions
kvn
parents: 13952
diff changeset
  6113
    }
35154
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  6114
    if (UseAESCTRIntrinsics){
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  6115
      StubRoutines::x86::_counter_shuffle_mask_addr = generate_counter_shuffle_mask();
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  6116
      StubRoutines::_counterMode_AESCrypt = generate_counterMode_AESCrypt_Parallel();
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35146
diff changeset
  6117
    }
18740
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  6118
36555
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  6119
    if (UseSHA1Intrinsics) {
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  6120
      StubRoutines::x86::_upper_word_mask_addr = generate_upper_word_mask();
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  6121
      StubRoutines::x86::_shuffle_byte_flip_mask_addr = generate_shuffle_byte_flip_mask();
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  6122
      StubRoutines::_sha1_implCompress = generate_sha1_implCompress(false, "sha1_implCompress");
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  6123
      StubRoutines::_sha1_implCompressMB = generate_sha1_implCompress(true, "sha1_implCompressMB");
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  6124
    }
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  6125
    if (UseSHA256Intrinsics) {
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  6126
      StubRoutines::x86::_k256_adr = (address)StubRoutines::x86::_k256;
38135
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  6127
      char* dst = (char*)StubRoutines::x86::_k256_W;
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  6128
      char* src = (char*)StubRoutines::x86::_k256;
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  6129
      for (int ii = 0; ii < 16; ++ii) {
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  6130
        memcpy(dst + 32 * ii,      src + 16 * ii, 16);
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  6131
        memcpy(dst + 32 * ii + 16, src + 16 * ii, 16);
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  6132
      }
e06e2d071465 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available)
jcivlin
parents: 38051
diff changeset
  6133
      StubRoutines::x86::_k256_W_adr = (address)StubRoutines::x86::_k256_W;
36555
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  6134
      StubRoutines::x86::_pshuffle_byte_flip_mask_addr = generate_pshuffle_byte_flip_mask();
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  6135
      StubRoutines::_sha256_implCompress = generate_sha256_implCompress(false, "sha256_implCompress");
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  6136
      StubRoutines::_sha256_implCompressMB = generate_sha256_implCompress(true, "sha256_implCompressMB");
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  6137
    }
42039
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  6138
    if (UseSHA512Intrinsics) {
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  6139
      StubRoutines::x86::_k512_W_addr = (address)StubRoutines::x86::_k512_W;
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  6140
      StubRoutines::x86::_pshuffle_byte_flip_mask_addr_sha512 = generate_pshuffle_byte_flip_mask_sha512();
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  6141
      StubRoutines::_sha512_implCompress = generate_sha512_implCompress(false, "sha512_implCompress");
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  6142
      StubRoutines::_sha512_implCompressMB = generate_sha512_implCompress(true, "sha512_implCompressMB");
db627462f2c9 8165381: Update for x86 SHA512 using AVX2
kvn
parents: 41333
diff changeset
  6143
    }
36555
4f37fd7a5a09 8150767: Enables SHA Extensions on x86
vdeshpande
parents: 35540
diff changeset
  6144
31404
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  6145
    // Generate GHASH intrinsics code
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  6146
    if (UseGHASHIntrinsics) {
52990
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  6147
    StubRoutines::x86::_ghash_long_swap_mask_addr = generate_ghash_long_swap_mask();
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  6148
    StubRoutines::x86::_ghash_byte_swap_mask_addr = generate_ghash_byte_swap_mask();
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  6149
      if (VM_Version::supports_avx()) {
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  6150
        StubRoutines::x86::_ghash_shuffmask_addr = ghash_shufflemask_addr();
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  6151
        StubRoutines::x86::_ghash_poly_addr = ghash_polynomial_addr();
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  6152
        StubRoutines::_ghash_processBlocks = generate_avx_ghash_processBlocks();
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  6153
      } else {
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  6154
        StubRoutines::_ghash_processBlocks = generate_ghash_processBlocks();
1ed8de9045a7 8214074: Ghash optimization using AVX instructions
ascarpino
parents: 52142
diff changeset
  6155
      }
31404
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  6156
    }
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 31129
diff changeset
  6157
50860
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  6158
    if (UseBASE64Intrinsics) {
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  6159
      StubRoutines::x86::_and_mask = base64_and_mask_addr();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  6160
      StubRoutines::x86::_bswap_mask = base64_bswap_mask_addr();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  6161
      StubRoutines::x86::_base64_charset = base64_charset_addr();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  6162
      StubRoutines::x86::_url_charset = base64url_charset_addr();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  6163
      StubRoutines::x86::_gather_mask = base64_gather_mask_addr();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  6164
      StubRoutines::x86::_left_shift_mask = base64_left_shift_mask_addr();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  6165
      StubRoutines::x86::_right_shift_mask = base64_right_shift_mask_addr();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  6166
      StubRoutines::_base64_encodeBlock = generate_base64_encodeBlock();
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  6167
    }
480a96a43b62 8205528: Base64 encoding algorithm using AVX512 instructions
kvn
parents: 50728
diff changeset
  6168
18740
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  6169
    // Safefetch stubs.
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  6170
    generate_safefetch("SafeFetch32", sizeof(int),     &StubRoutines::_safefetch32_entry,
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  6171
                                                       &StubRoutines::_safefetch32_fault_pc,
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  6172
                                                       &StubRoutines::_safefetch32_continuation_pc);
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  6173
    generate_safefetch("SafeFetchN", sizeof(intptr_t), &StubRoutines::_safefetchN_entry,
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  6174
                                                       &StubRoutines::_safefetchN_fault_pc,
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 18507
diff changeset
  6175
                                                       &StubRoutines::_safefetchN_continuation_pc);
52142
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  6176
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  6177
    BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  6178
    if (bs_nm != NULL) {
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  6179
      StubRoutines::x86::_method_entry_barrier = generate_method_entry_barrier();
ca0c25e01c5b 8210498: nmethod entry barriers
eosterlund
parents: 51996
diff changeset
  6180
    }
26434
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  6181
#ifdef COMPILER2
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  6182
    if (UseMultiplyToLenIntrinsic) {
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  6183
      StubRoutines::_multiplyToLen = generate_multiplyToLen();
09ad55e5f486 8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
kvn
parents: 22505
diff changeset
  6184
    }
31129
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  6185
    if (UseSquareToLenIntrinsic) {
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  6186
      StubRoutines::_squareToLen = generate_squareToLen();
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  6187
    }
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  6188
    if (UseMulAddIntrinsic) {
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  6189
      StubRoutines::_mulAdd = generate_mulAdd();
02ee7609f0e1 8081778: Use Intel x64 CPU instructions for RSA acceleration
kvn
parents: 30624
diff changeset
  6190
    }
31583
eb5bea7b4835 8130150: Implement BigInteger.montgomeryMultiply intrinsic
aph
parents: 31129
diff changeset
  6191
#ifndef _WINDOWS
eb5bea7b4835 8130150: Implement BigInteger.montgomeryMultiply intrinsic
aph
parents: 31129
diff changeset
  6192
    if (UseMontgomeryMultiplyIntrinsic) {
eb5bea7b4835 8130150: Implement BigInteger.montgomeryMultiply intrinsic
aph
parents: 31129
diff changeset
  6193
      StubRoutines::_montgomeryMultiply
eb5bea7b4835 8130150: Implement BigInteger.montgomeryMultiply intrinsic
aph
parents: 31129
diff changeset
  6194
        = CAST_FROM_FN_PTR(address, SharedRuntime::montgomery_multiply);
eb5bea7b4835 8130150: Implement BigInteger.montgomeryMultiply intrinsic
aph
parents: 31129
diff changeset
  6195
    }
eb5bea7b4835 8130150: Implement BigInteger.montgomeryMultiply intrinsic
aph
parents: 31129
diff changeset
  6196
    if (UseMontgomerySquareIntrinsic) {
eb5bea7b4835 8130150: Implement BigInteger.montgomeryMultiply intrinsic
aph
parents: 31129
diff changeset
  6197
      StubRoutines::_montgomerySquare
eb5bea7b4835 8130150: Implement BigInteger.montgomeryMultiply intrinsic
aph
parents: 31129
diff changeset
  6198
        = CAST_FROM_FN_PTR(address, SharedRuntime::montgomery_square);
eb5bea7b4835 8130150: Implement BigInteger.montgomeryMultiply intrinsic
aph
parents: 31129
diff changeset
  6199
    }
eb5bea7b4835 8130150: Implement BigInteger.montgomeryMultiply intrinsic
aph
parents: 31129
diff changeset
  6200
#endif // WINDOWS
eb5bea7b4835 8130150: Implement BigInteger.montgomeryMultiply intrinsic
aph
parents: 31129
diff changeset
  6201
#endif // COMPILER2
38238
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38135
diff changeset
  6202
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38135
diff changeset
  6203
    if (UseVectorizedMismatchIntrinsic) {
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38135
diff changeset
  6204
      StubRoutines::_vectorizedMismatch = generate_vectorizedMismatch();
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38135
diff changeset
  6205
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6206
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6207
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6208
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6209
  StubGenerator(CodeBuffer* code, bool all) : StubCodeGenerator(code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6210
    if (all) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6211
      generate_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6212
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6213
      generate_initial();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6214
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6215
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6216
}; // end class declaration
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6217
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  6218
#define UCM_TABLE_MAX_ENTRIES 16
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6219
void StubGenerator_generate(CodeBuffer* code, bool all) {
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  6220
  if (UnsafeCopyMemory::_table == NULL) {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  6221
    UnsafeCopyMemory::create_table(UCM_TABLE_MAX_ENTRIES);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54786
diff changeset
  6222
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6223
  StubGenerator g(code, all);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  6224
}