hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.s
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
Initial load
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 2004-2007 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
        # NOTE WELL!  The _Copy functions are called directly
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
	# from server-compiler-generated code via CallLeafNoFP,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
	# which means that they *must* either not use floating
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
	# point or use it in the same manner as does the server
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
	# compiler.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
	
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
        .globl _Copy_conjoint_bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
        .globl _Copy_arrayof_conjoint_bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
        .globl _Copy_conjoint_jshorts_atomic
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
	.globl _Copy_arrayof_conjoint_jshorts
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
        .globl _Copy_conjoint_jints_atomic
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
        .globl _Copy_arrayof_conjoint_jints
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
	.globl _Copy_conjoint_jlongs_atomic
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
	.globl _mmx_Copy_arrayof_conjoint_jshorts
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
        .globl _Atomic_cmpxchg_long
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
	.text
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
        .globl  SafeFetch32, Fetch32PFI, Fetch32Resume
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
        .globl  SafeFetchN
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
        ## TODO: avoid exposing Fetch32PFI and Fetch32Resume.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
        ## Instead, the signal handler would call a new SafeFetchTriage(FaultingEIP)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
        ## routine to vet the address.  If the address is the faulting LD then
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
        ## SafeFetchTriage() would return the resume-at EIP, otherwise null.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
	.type    SafeFetch32,@function
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
SafeFetch32:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
SafeFetchN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
         movl    0x8(%esp), %eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
         movl    0x4(%esp), %ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
Fetch32PFI:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
         movl    (%ecx), %eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
Fetch32Resume:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
         ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
        .globl  SpinPause
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
	.type   SpinPause,@function
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
SpinPause:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
        rep
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
        nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
        movl    $1, %eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
        # Support for void Copy::conjoint_bytes(void* from,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
        #                                       void* to,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
        #                                       size_t count)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
	.type    _Copy_conjoint_bytes,@function
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
_Copy_conjoint_bytes:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
        pushl    %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
        movl     4+12(%esp),%ecx      # count
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
        pushl    %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
        movl     8+ 4(%esp),%esi      # from
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
        movl     8+ 8(%esp),%edi      # to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
        cmpl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
        leal     -1(%esi,%ecx),%eax   # from + count - 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
        jbe      cb_CopyRight
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
        cmpl     %eax,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
        jbe      cb_CopyLeft
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
        # copy from low to high
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
cb_CopyRight:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
        cmpl     $3,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
        jbe      5f                   # <= 3 bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
        # align source address at dword address boundary
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
        movl     %ecx,%eax            # original count
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
        movl     $4,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
        subl     %esi,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
        andl     $3,%ecx              # prefix byte count
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
        jz       1f                   # no prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
        subl     %ecx,%eax            # byte count less prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
        # copy prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
        subl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
0:      movb     (%esi),%dl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
        movb     %dl,(%edi,%esi,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
        addl     $1,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
        jnz      0b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
        addl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
1:      movl     %eax,%ecx            # byte count less prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
        shrl     $2,%ecx              # dword count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
        jz       4f                   # no dwords to move
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
        cmpl     $32,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
        jbe      2f                   # <= 32 dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
        # copy aligned dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
        rep;     smovl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
        jmp      4f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
        # copy aligned dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
2:      subl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
3:      movl     (%esi),%edx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
        movl     %edx,(%edi,%esi,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
        addl     $4,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
        jnz      3b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
        addl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
4:      movl     %eax,%ecx            # byte count less prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
        andl     $3,%ecx              # suffix byte count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
        jz       7f                   # no suffix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
        # copy suffix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
5:      xorl     %eax,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
6:      movb     (%esi,%eax,1),%dl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
        movb     %dl,(%edi,%eax,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
        addl     $1,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
        jnz      6b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
7:      popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
        popl     %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
        # copy from high to low
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
cb_CopyLeft:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
        std
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
        leal     -4(%edi,%ecx),%edi   # to + count - 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
        movl     %eax,%esi            # from + count - 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
        movl     %ecx,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
        subl     $3,%esi              # from + count - 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
        cmpl     $3,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
        jbe      5f                   # <= 3 bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
1:      shrl     $2,%ecx              # dword count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
        jz       4f                   # no dwords to move
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
        cmpl     $32,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
        ja       3f                   # > 32 dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
        # copy dwords, aligned or not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
        subl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
2:      movl     (%esi),%edx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
        movl     %edx,(%edi,%esi,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
        subl     $4,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
        jnz      2b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
        addl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
        jmp      4f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
        # copy dwords, aligned or not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
3:      rep;     smovl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
4:      movl     %eax,%ecx            # byte count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
        andl     $3,%ecx              # suffix byte count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
        jz       7f                   # no suffix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
        # copy suffix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
5:      subl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
        addl     $3,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
6:      movb     (%esi),%dl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
        movb     %dl,(%edi,%esi,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
	subl     $1,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
        jnz      6b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
7:      cld
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
        popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
        popl     %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
        # Support for void Copy::arrayof_conjoint_bytes(void* from,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
        #                                               void* to,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
        #                                               size_t count)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
        #
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
        # Same as _Copy_conjoint_bytes, except no source alignment check.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
	.type    _Copy_arrayof_conjoint_bytes,@function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
_Copy_arrayof_conjoint_bytes:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
        pushl    %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
        movl     4+12(%esp),%ecx      # count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
        pushl    %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
        movl     8+ 4(%esp),%esi      # from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
        movl     8+ 8(%esp),%edi      # to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
        cmpl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
        leal     -1(%esi,%ecx),%eax   # from + count - 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
        jbe      acb_CopyRight
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
        cmpl     %eax,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
        jbe      acb_CopyLeft 
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
        # copy from low to high
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
acb_CopyRight:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
        cmpl     $3,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
        jbe      5f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
1:      movl     %ecx,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
        shrl     $2,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
        jz       4f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
        cmpl     $32,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
        ja       3f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
        # copy aligned dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
        subl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
2:      movl     (%esi),%edx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
        movl     %edx,(%edi,%esi,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
        addl     $4,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
        jnz      2b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
        addl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
        jmp      4f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
        # copy aligned dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
3:      rep;     smovl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
4:      movl     %eax,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
        andl     $3,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
        jz       7f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
        # copy suffix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
5:      xorl     %eax,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
6:      movb     (%esi,%eax,1),%dl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
        movb     %dl,(%edi,%eax,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
        addl     $1,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
        jnz      6b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
7:      popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
        popl     %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
acb_CopyLeft:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
        std
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
        leal     -4(%edi,%ecx),%edi   # to + count - 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
        movl     %eax,%esi            # from + count - 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
        movl     %ecx,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
        subl     $3,%esi              # from + count - 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
        cmpl     $3,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
        jbe      5f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
1:      shrl     $2,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
        jz       4f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
        cmpl     $32,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
        jbe      2f                   # <= 32 dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
        rep;     smovl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
        jmp      4f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
	.=.+8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
2:      subl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
3:      movl     (%esi),%edx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
        movl     %edx,(%edi,%esi,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
        subl     $4,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
        jnz      3b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
        addl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
4:      movl     %eax,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
        andl     $3,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
        jz       7f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
5:      subl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
        addl     $3,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
6:      movb     (%esi),%dl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
        movb     %dl,(%edi,%esi,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
	subl     $1,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
        jnz      6b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
7:      cld
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
        popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
        popl     %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
        # Support for void Copy::conjoint_jshorts_atomic(void* from,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
        #                                                void* to,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
        #                                                size_t count)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
	.type    _Copy_conjoint_jshorts_atomic,@function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
_Copy_conjoint_jshorts_atomic:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
        pushl    %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
        movl     4+12(%esp),%ecx      # count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
        pushl    %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
        movl     8+ 4(%esp),%esi      # from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
        movl     8+ 8(%esp),%edi      # to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
        cmpl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
        leal     -2(%esi,%ecx,2),%eax # from + count*2 - 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
        jbe      cs_CopyRight
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
        cmpl     %eax,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
        jbe      cs_CopyLeft 
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
        # copy from low to high
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
cs_CopyRight:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
        # align source address at dword address boundary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
        movl     %esi,%eax            # original from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
        andl     $3,%eax              # either 0 or 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
        jz       1f                   # no prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
        # copy prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
        movw     (%esi),%dx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
        movw     %dx,(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
        addl     %eax,%esi            # %eax == 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
        addl     %eax,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
1:      movl     %ecx,%eax            # word count less prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
        sarl     %ecx                 # dword count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
        jz       4f                   # no dwords to move
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
        cmpl     $32,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
        jbe      2f                   # <= 32 dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
        # copy aligned dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
        rep;     smovl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
        jmp      4f 
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
        # copy aligned dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
2:      subl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
3:      movl     (%esi),%edx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
        movl     %edx,(%edi,%esi,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
        addl     $4,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
        jnz      3b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
        addl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
4:      andl     $1,%eax              # suffix count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
        jz       5f                   # no suffix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
        # copy suffix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
        movw     (%esi),%dx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
        movw     %dx,(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
5:      popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
        popl     %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
        # copy from high to low
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
cs_CopyLeft:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
        std
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
        leal     -4(%edi,%ecx,2),%edi # to + count*2 - 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
        movl     %eax,%esi            # from + count*2 - 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
        movl     %ecx,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
        subl     $2,%esi              # from + count*2 - 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
1:      sarl     %ecx                 # dword count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
        jz       4f                   # no dwords to move
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
        cmpl     $32,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
        ja       3f                   # > 32 dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
        subl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
2:      movl     (%esi),%edx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
        movl     %edx,(%edi,%esi,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
        subl     $4,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
        jnz      2b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
        addl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
        jmp      4f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
3:      rep;     smovl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
4:      andl     $1,%eax              # suffix count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
        jz       5f                   # no suffix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
        # copy suffix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
        addl     $2,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
        addl     $2,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
        movw     (%esi),%dx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
        movw     %dx,(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
5:      cld
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
        popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
        popl     %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
        # Support for void Copy::arrayof_conjoint_jshorts(void* from,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
        #                                                 void* to,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
        #                                                 size_t count)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
	.type    _Copy_arrayof_conjoint_jshorts,@function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
_Copy_arrayof_conjoint_jshorts:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
        pushl    %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
        movl     4+12(%esp),%ecx      # count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
        pushl    %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
        movl     8+ 4(%esp),%esi      # from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
        movl     8+ 8(%esp),%edi      # to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
        cmpl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
        leal     -2(%esi,%ecx,2),%eax # from + count*2 - 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
        jbe      acs_CopyRight
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
        cmpl     %eax,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
        jbe      acs_CopyLeft 
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
acs_CopyRight:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
        movl     %ecx,%eax            # word count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
        sarl     %ecx                 # dword count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
        jz       4f                   # no dwords to move
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
        cmpl     $32,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
        jbe      2f                   # <= 32 dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
        # copy aligned dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
        rep;     smovl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
        jmp      4f 
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
        # copy aligned dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
        .=.+5
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
2:      subl     %esi,%edi 
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
3:      movl     (%esi),%edx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
        movl     %edx,(%edi,%esi,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
        addl     $4,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
        jnz      3b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
        addl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
4:      andl     $1,%eax              # suffix count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
        jz       5f                   # no suffix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
        # copy suffix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
        movw     (%esi),%dx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
        movw     %dx,(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
5:      popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
        popl     %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
acs_CopyLeft:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
        std
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
        leal     -4(%edi,%ecx,2),%edi # to + count*2 - 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
        movl     %eax,%esi            # from + count*2 - 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
        movl     %ecx,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
        subl     $2,%esi              # from + count*2 - 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
        sarl     %ecx                 # dword count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
        jz       4f                   # no dwords to move
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
        cmpl     $32,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
        ja       3f                   # > 32 dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
        subl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
2:      movl     (%esi),%edx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
        movl     %edx,(%edi,%esi,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
        subl     $4,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
        jnz      2b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
        addl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
        jmp      4f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
3:      rep;     smovl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
4:      andl     $1,%eax              # suffix count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
        jz       5f                   # no suffix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
        # copy suffix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
        addl     $2,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
        addl     $2,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
        movw     (%esi),%dx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
        movw     %dx,(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
5:      cld
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
        popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
        popl     %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
        # Support for void Copy::conjoint_jints_atomic(void* from,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
        #                                              void* to,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
        #                                              size_t count)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
        # Equivalent to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
        #   arrayof_conjoint_jints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
	.type    _Copy_conjoint_jints_atomic,@function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
	.type    _Copy_arrayof_conjoint_jints,@function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
_Copy_conjoint_jints_atomic:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
_Copy_arrayof_conjoint_jints:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
        pushl    %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
        movl     4+12(%esp),%ecx      # count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
        pushl    %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
        movl     8+ 4(%esp),%esi      # from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
        movl     8+ 8(%esp),%edi      # to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
        cmpl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
        leal     -4(%esi,%ecx,4),%eax # from + count*4 - 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
        jbe      ci_CopyRight
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
        cmpl     %eax,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
        jbe      ci_CopyLeft 
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
ci_CopyRight:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
        cmpl     $32,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
        jbe      2f                   # <= 32 dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
        rep;     smovl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
        popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
        popl     %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
        .=.+10
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
2:      subl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
3:      movl     (%esi),%edx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
        movl     %edx,(%edi,%esi,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
        addl     $4,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
        jnz      3b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
        popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
        popl     %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
ci_CopyLeft:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
        std
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
        leal     -4(%edi,%ecx,4),%edi # to + count*4 - 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
        cmpl     $32,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
        ja       3f                   # > 32 dwords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
        subl     %eax,%edi            # eax == from + count*4 - 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
2:      movl     (%eax),%edx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
        movl     %edx,(%edi,%eax,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
        subl     $4,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
        jnz      2b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
        cld
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
        popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
        popl     %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
3:      movl     %eax,%esi            # from + count*4 - 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
        rep;     smovl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
        cld
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
        popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
        popl     %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
	
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
        # Support for void Copy::conjoint_jlongs_atomic(jlong* from,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
        #                                               jlong* to,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
        #                                               size_t count)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
        #
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
        # 32-bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
        #
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
        # count treated as signed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
        #
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
        # if (from > to) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
        #   while (--count >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
        #     *to++ = *from++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
        #   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
        # } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
        #   while (--count >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
        #     to[count] = from[count];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
        #   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
        # }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
	.type    _Copy_conjoint_jlongs_atomic,@function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
_Copy_conjoint_jlongs_atomic:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
        movl     4+8(%esp),%ecx       # count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
        movl     4+0(%esp),%eax       # from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
        movl     4+4(%esp),%edx       # to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
        cmpl     %eax,%edx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
        jae      cla_CopyLeft
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
cla_CopyRight:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
        subl     %eax,%edx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
        jmp      2f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
1:      fildll   (%eax)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
        fistpll  (%edx,%eax,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
        addl     $8,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
2:      subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
        jge      1b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
3:      fildll   (%eax,%ecx,8)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
        fistpll  (%edx,%ecx,8)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
cla_CopyLeft:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
        jge      3b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
        # Support for void Copy::arrayof_conjoint_jshorts(void* from,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
        #                                                 void* to,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
        #                                                 size_t count)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
	.type    _mmx_Copy_arrayof_conjoint_jshorts,@function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
_mmx_Copy_arrayof_conjoint_jshorts:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
        pushl    %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
        movl     4+12(%esp),%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
        pushl    %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
        movl     8+ 4(%esp),%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
        movl     8+ 8(%esp),%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
        cmpl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
        leal     -2(%esi,%ecx,2),%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
        jbe      mmx_acs_CopyRight
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
        cmpl     %eax,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
        jbe      mmx_acs_CopyLeft
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
mmx_acs_CopyRight:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
        movl     %ecx,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
        sarl     %ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
        je       5f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
        cmpl     $33,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
        jae      3f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
1:      subl     %esi,%edi 
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
2:      movl     (%esi),%edx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
        movl     %edx,(%edi,%esi,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
        addl     $4,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
        jnz      2b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
        addl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
        jmp      5f 
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
3:      smovl # align to 8 bytes, we know we are 4 byte aligned to start
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
4:      .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
        movq     0(%esi),%mm0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
        addl     $64,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
        movq     8(%esi),%mm1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
        subl     $16,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
        movq     16(%esi),%mm2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
        movq     %mm0,-64(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
        movq     24(%esi),%mm0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
        movq     %mm1,-56(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
        movq     32(%esi),%mm1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
        movq     %mm2,-48(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
        movq     40(%esi),%mm2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
        movq     %mm0,-40(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
        movq     48(%esi),%mm0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
        movq     %mm1,-32(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
        movq     56(%esi),%mm1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
        movq     %mm2,-24(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
        movq     %mm0,-16(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
        addl     $64,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
        movq     %mm1,-8(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
        cmpl     $16,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
        jge      4b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
        emms
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
	testl    %ecx,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
	ja       1b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
5:      andl     $1,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
        je       7f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
6:      movw     (%esi),%dx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
        movw     %dx,(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
7:	popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
        popl     %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
mmx_acs_CopyLeft:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
        std
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
        leal     -4(%edi,%ecx,2),%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
        movl     %eax,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
        movl     %ecx,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
        subl     $2,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
        sarl     %ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
        je       4f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
        cmpl     $32,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
        ja       3f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
        subl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
2:      movl     (%esi),%edx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
        movl     %edx,(%edi,%esi,1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
        subl     $4,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
        subl     $1,%ecx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
        jnz      2b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
        addl     %esi,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
        jmp      4f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
3:      rep;     smovl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
4:      andl     $1,%eax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
        je       6f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
        addl     $2,%esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
        addl     $2,%edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
5:      movw     (%esi),%dx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
        movw     %dx,(%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
6:      cld
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
        popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
        popl     %esi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
        # Support for jlong Atomic::cmpxchg(jlong exchange_value,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
        #                                   volatile jlong* dest,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
        #                                   jlong compare_value,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
        #                                   bool is_MP)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
        #
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
        .p2align 4,,15
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
	.type    _Atomic_cmpxchg_long,@function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
_Atomic_cmpxchg_long:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
                                   #  8(%esp) : return PC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
        pushl    %ebx              #  4(%esp) : old %ebx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
        pushl    %edi              #  0(%esp) : old %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
        movl     12(%esp), %ebx    # 12(%esp) : exchange_value (low)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
        movl     16(%esp), %ecx    # 16(%esp) : exchange_value (high)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
        movl     24(%esp), %eax    # 24(%esp) : compare_value (low)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
        movl     28(%esp), %edx    # 28(%esp) : compare_value (high)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
        movl     20(%esp), %edi    # 20(%esp) : dest
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
        cmpl     $0, 32(%esp)      # 32(%esp) : is_MP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
        je       1f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
        lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
1:      cmpxchg8b (%edi)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
        popl     %edi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
        popl     %ebx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
        ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652