/
/
/
/
/
/ questions.
/
// NOTE WELL! The _Copy functions are called directly
// from server-compiler-generated code via CallLeafNoFP,
// which means that they *must* either not use floating
// point or use it in the same manner as does the server
// compiler.
.align 16
.align 16
.align 16
// Prototype: int SafeFetch32 (int * Adr, int ErrValue)
.align 16
// Prototype: intptr_t SafeFetchN (intptr_t * Adr, intptr_t ErrValue)
.align 16
/ void* to,
/
.align 16
jmp 7f
.align 16
jnz 1b
jz 3f
/ can't use it as a base register
3: testq $2,%r8 / check for trailing word
jz 4f
movw 8(%rax),%si / copy trailing word
movw %si,8(%rcx)
addq $2,%rcx
4: testq $1,%r8 / check for trailing byte
jz 5f
movb -1(%rdi,%r8,1),%al / copy trailing byte
movb %al,8(%rcx)
5: ret
.align 16
6: movq -24(%rax,%rdx,8),%rsi
movq %rsi,-24(%rcx,%rdx,8)
movq -16(%rax,%rdx,8),%rsi
movq %rsi,-16(%rcx,%rdx,8)
movq -8(%rax,%rdx,8),%rsi
movq %rsi,-8(%rcx,%rdx,8)
movq (%rax,%rdx,8),%rsi
movq %rsi,(%rcx,%rdx,8)
7: addq $4,%rdx
jle 6b
subq $4,%rdx
jl 1b
jmp 2b
acb_CopyLeft:
testq $1,%r8 / check for trailing byte
jz 1f
movb -1(%rdi,%r8,1),%cl / copy trailing byte
movb %cl,-1(%rsi,%r8,1)
subq $1,%r8 / adjust for possible trailing word
1: testq $2,%r8 / check for trailing word
jz 2f
movw -2(%rdi,%r8,1),%cx / copy trailing word
movw %cx,-2(%rsi,%r8,1)
2: testq $4,%r8 / check for trailing dword
jz 5f
movl (%rdi,%rdx,8),%ecx / copy trailing dword
movl %ecx,(%rsi,%rdx,8)
jmp 5f
.align 16
3: movq -8(%rdi,%rdx,8),%rcx
movq %rcx,-8(%rsi,%rdx,8)
subq $1,%rdx
jnz 3b
ret
.align 16
4: movq 24(%rdi,%rdx,8),%rcx
movq %rcx,24(%rsi,%rdx,8)
movq 16(%rdi,%rdx,8),%rcx
movq %rcx,16(%rsi,%rdx,8)
movq 8(%rdi,%rdx,8),%rcx
movq %rcx,8(%rsi,%rdx,8)
movq (%rdi,%rdx,8),%rcx
movq %rcx,(%rsi,%rdx,8)
5: subq $4,%rdx
jge 4b
addq $4,%rdx
jg 3b
ret
/ Support for void Copy::arrayof_conjoint_jshorts(void* from,
/ void* to,
/ size_t count)
/ Equivalent to
/ conjoint_jshorts_atomic
/
/ let the hardware handle it. The tow or four words within dwords
/ or qwords that span cache line boundaries will still be loaded
/ and stored atomically.
/
/ rdi - from
/ rsi - to
/ rdx - count, treated as ssize_t
/
.align 16
_Copy_arrayof_conjoint_jshorts:
_Copy_conjoint_jshorts_atomic:
movq %rdx,%r8 / word count
shrq $2,%rdx / qword count
cmpq %rdi,%rsi
leaq -2(%rdi,%r8,2),%rax / from + wcount*2 - 2
jbe acs_CopyRight
cmpq %rax,%rsi
jbe acs_CopyLeft
acs_CopyRight:
leaq -8(%rdi,%rdx,8),%rax / from + qcount*8 - 8
leaq -8(%rsi,%rdx,8),%rcx / to + qcount*8 - 8
negq %rdx
jmp 6f
1: movq 8(%rax,%rdx,8),%rsi
movq %rsi,8(%rcx,%rdx,8)
addq $1,%rdx
jnz 1b
2: testq $2,%r8 / check for trailing dword
jz 3f
movl 8(%rax),%esi / copy trailing dword
movl %esi,8(%rcx)
addq $4,%rcx / original %rsi is trashed, so we
jz 4f
4: ret
.align 16
jle 5b
jl 1b
jmp 2b
jz 1f
jz 4f
jmp 4f
jnz 2b
.align 16
jge 3b
jg 2b
/ Equivalent to
/
/
/
.align 16
jmp 5f
.align 16
jnz 1b
jz 3f
3: ret
.align 16
jle 4b
jl 1b
jmp 2b
jz 3f
jmp 3f
jnz 1b
.align 16
jge 2b
jg 1b
/ Equivalent to
/
/
.align 16
jmp 3f
jnz 1b
.align 16
jle 2b
jl 1b
jnz 4b
.align 16
jge 5b
jg 4b