hotspot/src/os_cpu/linux_x86/vm/copy_linux_x86.inline.hpp
author martin
Fri, 11 Jun 2010 18:55:45 -0700
changeset 5786 f60ef38202e7
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6944584: Improvements to subprocess handling on Unix Summary: use thread pool for reaper thread; move most I/O operations out of reaper thread Reviewed-by: michaelm, hiroshi
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
  (void)memmove(to, from, count * HeapWordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
  // Same as pd_aligned_conjoint_words, except includes a zero-count check.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  intx temp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  __asm__ volatile("        testl   %6,%6         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
                   "        jz      7f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
                   "        cmpl    %4,%5         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
                   "        leal    -4(%4,%6,4),%3;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
                   "        jbe     1f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
                   "        cmpl    %7,%5         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
                   "        jbe     4f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
                   "1:      cmpl    $32,%6        ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
                   "        ja      3f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
                   "        subl    %4,%1         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
                   "2:      movl    (%4),%3       ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
                   "        movl    %7,(%5,%4,1)  ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
                   "        addl    $4,%0         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
                   "        subl    $1,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
                   "        jnz     2b            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
                   "        jmp     7f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
                   "3:      rep;    smovl         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
                   "        jmp     7f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
                   "4:      cmpl    $32,%2        ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
                   "        movl    %7,%0         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
                   "        leal    -4(%5,%6,4),%1;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
                   "        ja      6f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
                   "        subl    %4,%1         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
                   "5:      movl    (%4),%3       ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
                   "        movl    %7,(%5,%4,1)  ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
                   "        subl    $4,%0         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
                   "        subl    $1,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
                   "        jnz     5b            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
                   "        jmp     7f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
                   "6:      std                   ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
                   "        rep;    smovl         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
                   "        cld                   ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
                   "7:      nop                    "
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
                   : "=S" (from), "=D" (to), "=c" (count), "=r" (temp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
                   : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
                   : "memory", "flags");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  switch (count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  case 8:  to[7] = from[7];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  case 7:  to[6] = from[6];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  case 6:  to[5] = from[5];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  case 5:  to[4] = from[4];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  case 4:  to[3] = from[3];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  case 3:  to[2] = from[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  case 2:  to[1] = from[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  case 1:  to[0] = from[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  case 0:  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    (void)memcpy(to, from, count * HeapWordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // Same as pd_aligned_disjoint_words, except includes a zero-count check.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  intx temp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  __asm__ volatile("        testl   %6,%6       ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
                   "        jz      3f          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
                   "        cmpl    $32,%6      ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
                   "        ja      2f          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
                   "        subl    %4,%1       ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
                   "1:      movl    (%4),%3     ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
                   "        movl    %7,(%5,%4,1);"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
                   "        addl    $4,%0       ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
                   "        subl    $1,%2        ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
                   "        jnz     1b          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
                   "        jmp     3f          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
                   "2:      rep;    smovl       ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
                   "3:      nop                  "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
                   : "=S" (from), "=D" (to), "=c" (count), "=r" (temp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
                   : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
                   : "memory", "cc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  switch (count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  case 8:  to[7] = from[7];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  case 7:  to[6] = from[6];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  case 6:  to[5] = from[5];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  case 5:  to[4] = from[4];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  case 4:  to[3] = from[3];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  case 3:  to[2] = from[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  case 2:  to[1] = from[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  case 1:  to[0] = from[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  case 0:  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    while (count-- > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
      *to++ = *from++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // pd_disjoint_words is word-atomic in this implementation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  pd_disjoint_words(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  (void)memmove(to, from, count * HeapWordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // Same as pd_conjoint_words, except no zero-count check.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  intx temp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  __asm__ volatile("        cmpl    %4,%5         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
                   "        leal    -4(%4,%6,4),%3;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
                   "        jbe     1f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
                   "        cmpl    %7,%5         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
                   "        jbe     4f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
                   "1:      cmpl    $32,%6        ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
                   "        ja      3f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
                   "        subl    %4,%1         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
                   "2:      movl    (%4),%3       ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
                   "        movl    %7,(%5,%4,1)  ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
                   "        addl    $4,%0         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
                   "        subl    $1,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
                   "        jnz     2b            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
                   "        jmp     7f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
                   "3:      rep;    smovl         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
                   "        jmp     7f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
                   "4:      cmpl    $32,%2        ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
                   "        movl    %7,%0         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
                   "        leal    -4(%5,%6,4),%1;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
                   "        ja      6f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
                   "        subl    %4,%1         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
                   "5:      movl    (%4),%3       ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
                   "        movl    %7,(%5,%4,1)  ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
                   "        subl    $4,%0         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
                   "        subl    $1,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
                   "        jnz     5b            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
                   "        jmp     7f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
                   "6:      std                   ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
                   "        rep;    smovl         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
                   "        cld                   ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
                   "7:      nop                    "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
                   : "=S" (from), "=D" (to), "=c" (count), "=r" (temp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
                   : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
                   : "memory", "flags");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  pd_disjoint_words(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  // Same as pd_disjoint_words, except no zero-count check.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  intx temp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  __asm__ volatile("        cmpl    $32,%6      ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
                   "        ja      2f          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
                   "        subl    %4,%1       ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
                   "1:      movl    (%4),%3     ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
                   "        movl    %7,(%5,%4,1);"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
                   "        addl    $4,%0       ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
                   "        subl    $1,%2        ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
                   "        jnz     1b          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
                   "        jmp     3f          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
                   "2:      rep;    smovl       ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
                   "3:      nop                  "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
                   : "=S" (from), "=D" (to), "=c" (count), "=r" (temp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
                   : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
                   : "memory", "cc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
static void pd_conjoint_bytes(void* from, void* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  (void)memmove(to, from, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  intx temp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  __asm__ volatile("        testl   %6,%6          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
                   "        jz      13f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
                   "        cmpl    %4,%5          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
                   "        leal    -1(%4,%6),%3   ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
                   "        jbe     1f             ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
                   "        cmpl    %7,%5          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
                   "        jbe     8f             ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
                   "1:      cmpl    $3,%6          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
                   "        jbe     6f             ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
                   "        movl    %6,%3          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
                   "        movl    $4,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
                   "        subl    %4,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
                   "        andl    $3,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
                   "        jz      2f             ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
                   "        subl    %6,%3          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
                   "        rep;    smovb          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
                   "2:      movl    %7,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
                   "        shrl    $2,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
                   "        jz      5f             ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
                   "        cmpl    $32,%2         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
                   "        ja      4f             ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
                   "        subl    %4,%1          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
                   "3:      movl    (%4),%%edx     ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
                   "        movl    %%edx,(%5,%4,1);"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
                   "        addl    $4,%0          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
                   "        subl    $1,%2           ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
                   "        jnz     3b             ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
                   "        addl    %4,%1          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
                   "        jmp     5f             ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
                   "4:      rep;    smovl          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
                   "5:      movl    %7,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
                   "        andl    $3,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
                   "        jz      13f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
                   "6:      xorl    %7,%3          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
                   "7:      movb    (%4,%7,1),%%dl ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
                   "        movb    %%dl,(%5,%7,1) ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
                   "        addl    $1,%3          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
                   "        subl    $1,%2           ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
                   "        jnz     7b             ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
                   "        jmp     13f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
                   "8:      std                    ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
                   "        cmpl    $12,%2         ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
                   "        ja      9f             ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
                   "        movl    %7,%0          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
                   "        leal    -1(%6,%5),%1   ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
                   "        jmp     11f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
                   "9:      xchgl   %3,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
                   "        movl    %6,%0          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
                   "        addl    $1,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
                   "        leal    -1(%7,%5),%1   ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
                   "        andl    $3,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
                   "        jz      10f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
                   "        subl    %6,%3          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
                   "        rep;    smovb          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
                   "10:     movl    %7,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
                   "        subl    $3,%0          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
                   "        shrl    $2,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
                   "        subl    $3,%1          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
                   "        rep;    smovl          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
                   "        andl    $3,%3          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
                   "        jz      12f            ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
                   "        movl    %7,%2          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
                   "        addl    $3,%0          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
                   "        addl    $3,%1          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
                   "11:     rep;    smovb          ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
                   "12:     cld                    ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
                   "13:     nop                    ;"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
                   : "=S" (from), "=D" (to), "=c" (count), "=r" (temp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
                   : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
                   : "memory", "flags", "%edx");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  pd_conjoint_bytes(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  _Copy_conjoint_jshorts_atomic(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  _Copy_conjoint_jints_atomic(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  assert(HeapWordSize == BytesPerInt, "heapwords and jints must be the same size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  // pd_conjoint_words is word-atomic in this implementation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  pd_conjoint_words((HeapWord*)from, (HeapWord*)to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  _Copy_conjoint_jlongs_atomic(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  // Guarantee use of fild/fistp or xmm regs via some asm code, because compilers won't.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  if (from > to) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
    while (count-- > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
      __asm__ volatile("fildll (%0); fistpll (%1)"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
                       :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
                       : "r" (from), "r" (to)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
                       : "memory" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
      ++from;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
      ++to;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    while (count-- > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
      __asm__ volatile("fildll (%0,%2,8); fistpll (%1,%2,8)"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
                       :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
                       : "r" (from), "r" (to), "r" (count)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
                       : "memory" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  _Copy_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  assert(HeapWordSize == BytesPerOop, "heapwords and oops must be the same size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  // pd_conjoint_words is word-atomic in this implementation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  pd_conjoint_words((HeapWord*)from, (HeapWord*)to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  _Copy_arrayof_conjoint_bytes(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  _Copy_arrayof_conjoint_jshorts(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
   _Copy_arrayof_conjoint_jints(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  _Copy_arrayof_conjoint_jlongs(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  _Copy_arrayof_conjoint_jlongs(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
}