hotspot/src/os_cpu/bsd_x86/vm/copy_bsd_x86.inline.hpp
author prr
Fri, 23 May 2014 09:05:24 -0700
changeset 24567 a0ebe5fd56ff
parent 10565 dc90c239f4ec
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     1
/*
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     2
 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     4
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     7
 * published by the Free Software Foundation.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     8
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    13
 * accompanied this code).
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    14
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    18
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    21
 * questions.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    22
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    23
 */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    24
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    25
#ifndef OS_CPU_BSD_X86_VM_COPY_BSD_X86_INLINE_HPP
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    26
#define OS_CPU_BSD_X86_VM_COPY_BSD_X86_INLINE_HPP
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    27
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    28
static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    29
#ifdef AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    30
  (void)memmove(to, from, count * HeapWordSize);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    31
#else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    32
  // Includes a zero-count check.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    33
  intx temp;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    34
  __asm__ volatile("        testl   %6,%6         ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    35
                   "        jz      7f            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    36
                   "        cmpl    %4,%5         ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    37
                   "        leal    -4(%4,%6,4),%3;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    38
                   "        jbe     1f            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    39
                   "        cmpl    %7,%5         ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    40
                   "        jbe     4f            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    41
                   "1:      cmpl    $32,%6        ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    42
                   "        ja      3f            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    43
                   "        subl    %4,%1         ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    44
                   "2:      movl    (%4),%3       ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    45
                   "        movl    %7,(%5,%4,1)  ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    46
                   "        addl    $4,%0         ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    47
                   "        subl    $1,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    48
                   "        jnz     2b            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    49
                   "        jmp     7f            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    50
                   "3:      rep;    smovl         ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    51
                   "        jmp     7f            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    52
                   "4:      cmpl    $32,%2        ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    53
                   "        movl    %7,%0         ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    54
                   "        leal    -4(%5,%6,4),%1;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    55
                   "        ja      6f            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    56
                   "        subl    %4,%1         ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    57
                   "5:      movl    (%4),%3       ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    58
                   "        movl    %7,(%5,%4,1)  ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    59
                   "        subl    $4,%0         ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    60
                   "        subl    $1,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    61
                   "        jnz     5b            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    62
                   "        jmp     7f            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    63
                   "6:      std                   ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    64
                   "        rep;    smovl         ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    65
                   "        cld                   ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    66
                   "7:      nop                    "
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    67
                   : "=S" (from), "=D" (to), "=c" (count), "=r" (temp)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    68
                   : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    69
                   : "memory", "flags");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    70
#endif // AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    71
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    72
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    73
static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    74
#ifdef AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    75
  switch (count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    76
  case 8:  to[7] = from[7];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    77
  case 7:  to[6] = from[6];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    78
  case 6:  to[5] = from[5];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    79
  case 5:  to[4] = from[4];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    80
  case 4:  to[3] = from[3];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    81
  case 3:  to[2] = from[2];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    82
  case 2:  to[1] = from[1];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    83
  case 1:  to[0] = from[0];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    84
  case 0:  break;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    85
  default:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    86
    (void)memcpy(to, from, count * HeapWordSize);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    87
    break;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    88
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    89
#else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    90
  // Includes a zero-count check.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    91
  intx temp;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    92
  __asm__ volatile("        testl   %6,%6       ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    93
                   "        jz      3f          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    94
                   "        cmpl    $32,%6      ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    95
                   "        ja      2f          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    96
                   "        subl    %4,%1       ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    97
                   "1:      movl    (%4),%3     ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    98
                   "        movl    %7,(%5,%4,1);"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    99
                   "        addl    $4,%0       ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   100
                   "        subl    $1,%2        ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   101
                   "        jnz     1b          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   102
                   "        jmp     3f          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   103
                   "2:      rep;    smovl       ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   104
                   "3:      nop                  "
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   105
                   : "=S" (from), "=D" (to), "=c" (count), "=r" (temp)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   106
                   : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   107
                   : "memory", "cc");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   108
#endif // AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   109
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   110
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   111
static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   112
#ifdef AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   113
  switch (count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   114
  case 8:  to[7] = from[7];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   115
  case 7:  to[6] = from[6];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   116
  case 6:  to[5] = from[5];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   117
  case 5:  to[4] = from[4];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   118
  case 4:  to[3] = from[3];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   119
  case 3:  to[2] = from[2];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   120
  case 2:  to[1] = from[1];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   121
  case 1:  to[0] = from[0];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   122
  case 0:  break;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   123
  default:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   124
    while (count-- > 0) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   125
      *to++ = *from++;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   126
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   127
    break;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   128
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   129
#else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   130
  // pd_disjoint_words is word-atomic in this implementation.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   131
  pd_disjoint_words(from, to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   132
#endif // AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   133
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   134
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   135
static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   136
  pd_conjoint_words(from, to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   137
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   138
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   139
static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   140
  pd_disjoint_words(from, to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   141
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   142
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   143
static void pd_conjoint_bytes(void* from, void* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   144
#ifdef AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   145
  (void)memmove(to, from, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   146
#else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   147
  // Includes a zero-count check.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   148
  intx temp;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   149
  __asm__ volatile("        testl   %6,%6          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   150
                   "        jz      13f            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   151
                   "        cmpl    %4,%5          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   152
                   "        leal    -1(%4,%6),%3   ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   153
                   "        jbe     1f             ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   154
                   "        cmpl    %7,%5          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   155
                   "        jbe     8f             ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   156
                   "1:      cmpl    $3,%6          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   157
                   "        jbe     6f             ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   158
                   "        movl    %6,%3          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   159
                   "        movl    $4,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   160
                   "        subl    %4,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   161
                   "        andl    $3,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   162
                   "        jz      2f             ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   163
                   "        subl    %6,%3          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   164
                   "        rep;    smovb          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   165
                   "2:      movl    %7,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   166
                   "        shrl    $2,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   167
                   "        jz      5f             ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   168
                   "        cmpl    $32,%2         ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   169
                   "        ja      4f             ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   170
                   "        subl    %4,%1          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   171
                   "3:      movl    (%4),%%edx     ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   172
                   "        movl    %%edx,(%5,%4,1);"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   173
                   "        addl    $4,%0          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   174
                   "        subl    $1,%2           ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   175
                   "        jnz     3b             ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   176
                   "        addl    %4,%1          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   177
                   "        jmp     5f             ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   178
                   "4:      rep;    smovl          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   179
                   "5:      movl    %7,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   180
                   "        andl    $3,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   181
                   "        jz      13f            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   182
                   "6:      xorl    %7,%3          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   183
                   "7:      movb    (%4,%7,1),%%dl ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   184
                   "        movb    %%dl,(%5,%7,1) ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   185
                   "        addl    $1,%3          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   186
                   "        subl    $1,%2           ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   187
                   "        jnz     7b             ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   188
                   "        jmp     13f            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   189
                   "8:      std                    ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   190
                   "        cmpl    $12,%2         ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   191
                   "        ja      9f             ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   192
                   "        movl    %7,%0          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   193
                   "        leal    -1(%6,%5),%1   ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   194
                   "        jmp     11f            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   195
                   "9:      xchgl   %3,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   196
                   "        movl    %6,%0          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   197
                   "        addl    $1,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   198
                   "        leal    -1(%7,%5),%1   ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   199
                   "        andl    $3,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   200
                   "        jz      10f            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   201
                   "        subl    %6,%3          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   202
                   "        rep;    smovb          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   203
                   "10:     movl    %7,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   204
                   "        subl    $3,%0          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   205
                   "        shrl    $2,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   206
                   "        subl    $3,%1          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   207
                   "        rep;    smovl          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   208
                   "        andl    $3,%3          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   209
                   "        jz      12f            ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   210
                   "        movl    %7,%2          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   211
                   "        addl    $3,%0          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   212
                   "        addl    $3,%1          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   213
                   "11:     rep;    smovb          ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   214
                   "12:     cld                    ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   215
                   "13:     nop                    ;"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   216
                   : "=S" (from), "=D" (to), "=c" (count), "=r" (temp)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   217
                   : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   218
                   : "memory", "flags", "%edx");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   219
#endif // AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   220
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   221
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   222
static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   223
  pd_conjoint_bytes(from, to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   224
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   225
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   226
static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   227
  _Copy_conjoint_jshorts_atomic(from, to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   228
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   229
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   230
static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   231
#ifdef AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   232
  _Copy_conjoint_jints_atomic(from, to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   233
#else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   234
  assert(HeapWordSize == BytesPerInt, "heapwords and jints must be the same size");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   235
  // pd_conjoint_words is word-atomic in this implementation.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   236
  pd_conjoint_words((HeapWord*)from, (HeapWord*)to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   237
#endif // AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   238
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   239
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   240
static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   241
#ifdef AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   242
  _Copy_conjoint_jlongs_atomic(from, to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   243
#else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   244
  // Guarantee use of fild/fistp or xmm regs via some asm code, because compilers won't.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   245
  if (from > to) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   246
    while (count-- > 0) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   247
      __asm__ volatile("fildll (%0); fistpll (%1)"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   248
                       :
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   249
                       : "r" (from), "r" (to)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   250
                       : "memory" );
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   251
      ++from;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   252
      ++to;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   253
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   254
  } else {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   255
    while (count-- > 0) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   256
      __asm__ volatile("fildll (%0,%2,8); fistpll (%1,%2,8)"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   257
                       :
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   258
                       : "r" (from), "r" (to), "r" (count)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   259
                       : "memory" );
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   260
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   261
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   262
#endif // AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   263
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   264
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   265
static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   266
#ifdef AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   267
  assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   268
  _Copy_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   269
#else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   270
  assert(HeapWordSize == BytesPerOop, "heapwords and oops must be the same size");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   271
  // pd_conjoint_words is word-atomic in this implementation.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   272
  pd_conjoint_words((HeapWord*)from, (HeapWord*)to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   273
#endif // AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   274
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   275
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   276
static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   277
  _Copy_arrayof_conjoint_bytes(from, to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   278
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   279
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   280
static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   281
  _Copy_arrayof_conjoint_jshorts(from, to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   282
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   283
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   284
static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   285
#ifdef AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   286
   _Copy_arrayof_conjoint_jints(from, to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   287
#else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   288
  pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   289
#endif // AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   290
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   291
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   292
static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   293
#ifdef AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   294
  _Copy_arrayof_conjoint_jlongs(from, to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   295
#else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   296
  pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   297
#endif // AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   298
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   299
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   300
static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   301
#ifdef AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   302
  assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   303
  _Copy_arrayof_conjoint_jlongs(from, to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   304
#else
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   305
  pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   306
#endif // AMD64
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   307
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   308
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   309
#endif // OS_CPU_BSD_X86_VM_COPY_BSD_X86_INLINE_HPP