src/hotspot/os_cpu/windows_x86/copy_windows_x86.inline.hpp
author darcy
Tue, 12 Nov 2019 10:45:23 -0800
changeset 59037 3d2575331a41
parent 53244 9807daeb47c4
permissions -rw-r--r--
8233940: Preview API tests for String methods should use ${jdk.version} as -source arg Reviewed-by: jlaskey, jlahoda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 48951
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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 48951
diff changeset
    25
#ifndef OS_CPU_WINDOWS_X86_COPY_WINDOWS_X86_INLINE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 48951
diff changeset
    26
#define OS_CPU_WINDOWS_X86_COPY_WINDOWS_X86_INLINE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
    28
static void pd_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
  (void)memmove(to, from, count * HeapWordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
    32
static void pd_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  switch (count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  case 8:  to[7] = from[7];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  case 7:  to[6] = from[6];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  case 6:  to[5] = from[5];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  case 5:  to[4] = from[4];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  case 4:  to[3] = from[3];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  case 3:  to[2] = from[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  case 2:  to[1] = from[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  case 1:  to[0] = from[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  case 0:  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    (void)memcpy(to, from, count * HeapWordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  (void)memcpy(to, from, count * HeapWordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
    53
static void pd_disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  switch (count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  case 8:  to[7] = from[7];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  case 7:  to[6] = from[6];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  case 6:  to[5] = from[5];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  case 5:  to[4] = from[4];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  case 4:  to[3] = from[3];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  case 3:  to[2] = from[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  case 2:  to[1] = from[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  case 1:  to[0] = from[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  case 0:  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  default: while (count-- > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
             *to++ = *from++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
           }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
    71
static void pd_aligned_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  (void)memmove(to, from, count * HeapWordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
    75
static void pd_aligned_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  pd_disjoint_words(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
    79
static void pd_conjoint_bytes(const void* from, void* to, size_t count) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  (void)memmove(to, from, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
    83
static void pd_conjoint_bytes_atomic(const void* from, void* to, size_t count) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  pd_conjoint_bytes(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
    87
static void pd_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {
10743
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
    88
  if (from > to) {
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
    89
    while (count-- > 0) {
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
    90
      // Copy forwards
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
    91
      *to++ = *from++;
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
    92
    }
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
    93
  } else {
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
    94
    from += count - 1;
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
    95
    to   += count - 1;
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
    96
    while (count-- > 0) {
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
    97
      // Copy backwards
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
    98
      *to-- = *from--;
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
    99
    }
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
   100
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
   103
static void pd_conjoint_jints_atomic(const jint* from, jint* to, size_t count) {
10743
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
   104
  if (from > to) {
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
   105
    while (count-- > 0) {
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
   106
      // Copy forwards
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
   107
      *to++ = *from++;
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
   108
    }
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
   109
  } else {
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
   110
    from += count - 1;
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
   111
    to   += count - 1;
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
   112
    while (count-- > 0) {
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
   113
      // Copy backwards
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
   114
      *to-- = *from--;
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
   115
    }
2ee610c1fe49 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents: 7397
diff changeset
   116
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
   119
static void pd_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
   122
  pd_conjoint_oops_atomic((const oop*)from, (oop*)to, count);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // Guarantee use of fild/fistp or xmm regs via some asm code, because compilers won't.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  __asm {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    mov    eax, from;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    mov    edx, to;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    mov    ecx, count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    cmp    eax, edx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    jbe    downtest;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    jmp    uptest;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  up:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    fild   qword ptr [eax];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    fistp  qword ptr [edx];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    add    eax, 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    add    edx, 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  uptest:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    sub    ecx, 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    jge    up;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    jmp    done;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  down:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    fild   qword ptr [eax][ecx*8];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    fistp  qword ptr [edx][ecx*8];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  downtest:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    sub    ecx, 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    jge    down;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  done:;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
   152
static void pd_conjoint_oops_atomic(const oop* from, oop* to, size_t count) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // Do better than this: inline memmove body  NEEDS CLEANUP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  if (from > to) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    while (count-- > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
      // Copy forwards
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
      *to++ = *from++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    from += count - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    to   += count - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    while (count-- > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
      // Copy backwards
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
      *to-- = *from--;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
   169
static void pd_arrayof_conjoint_bytes(const HeapWord* from, HeapWord* to, size_t count) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
#ifdef AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  pd_conjoint_bytes_atomic(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  pd_conjoint_bytes(from, to, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
#endif // AMD64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
   177
static void pd_arrayof_conjoint_jshorts(const HeapWord* from, HeapWord* to, size_t count) {
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
   178
  pd_conjoint_jshorts_atomic((const jshort*)from, (jshort*)to, count);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
   181
static void pd_arrayof_conjoint_jints(const HeapWord* from, HeapWord* to, size_t count) {
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
   182
  pd_conjoint_jints_atomic((const jint*)from, (jint*)to, count);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
   185
static void pd_arrayof_conjoint_jlongs(const HeapWord* from, HeapWord* to, size_t count) {
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
   186
  pd_conjoint_jlongs_atomic((const jlong*)from, (jlong*)to, count);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
48951
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
   189
static void pd_arrayof_conjoint_oops(const HeapWord* from, HeapWord* to, size_t count) {
950c35ea6237 8165929: Constify arguments of Copy methods
coleenp
parents: 47216
diff changeset
   190
  pd_conjoint_oops_atomic((const oop*)from, (oop*)to, count);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
}
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   192
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 48951
diff changeset
   193
#endif // OS_CPU_WINDOWS_X86_COPY_WINDOWS_X86_INLINE_HPP