背景
了解arraycopy的实现,是浅拷贝还是深拷贝
arrays
在了解arraycopy
之前,先了解arrays
在jls里面有很详细的描述
In the Java programming language, arrays are objects (§4.3.1), are dynamically created
An array object contains a number of variables. The number of variables may be zero, in which case the array is said to be empty. The variables contained in an array have no names; instead they are referenced by array access expressions that use non-negative integer index values. These variables are called the components of the array. If an array has n components, we say n is the length of the array; the components of the array are referenced using integer indices from 0 to n - 1, inclusive.
arrays:
- 类型:
Object
- arrays对象持有的是变量
variables
变量 variables
A variable is a storage location and has an associated type, sometimes called its compile-time type, that is either a primitive type (§4.2) or a reference type (§4.3).
A variable's value is changed by an assignment (§15.26) or by a prefix or postfix ++ (increment) or -- (decrement) operator (§15.14.2, §15.14.3, §15.15.1, §15.15.2).
variable 由两部分组成:
- type
- primitive type
- reference type
- value
- primitive value
- reference value
4.3.1 Objects
An object is a class instance or an array.
The reference values (often just references) are pointers to these objects, and a
special null reference, which refers to no object.
jni 实现
src\hotspot\share\oops\objArrayKlass.cpp
void ObjArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d,
int dst_pos, int length, TRAPS) {
assert(s->is_objArray(), "must be obj array");
if (!d->is_objArray()) {
ResourceMark rm(THREAD);
stringStream ss;
if (d->is_typeArray()) {
ss.print("arraycopy: type mismatch: can not copy object array[] into %s[]",
type2name_tab[ArrayKlass::cast(d->klass())->element_type()]);
} else {
ss.print("arraycopy: destination type %s is not an array", d->klass()->external_name());
}
THROW_MSG(vmSymbols::java_lang_ArrayStoreException(), ss.as_string());
}
// Check is all offsets and lengths are non negative
if (src_pos < 0 || dst_pos < 0 || length < 0) {
// Pass specific exception reason.
ResourceMark rm(THREAD);
stringStream ss;
if (src_pos < 0) {
ss.print("arraycopy: source index %d out of bounds for object array[%d]",
src_pos, s->length());
} else if (dst_pos < 0) {
ss.print("arraycopy: destination index %d out of bounds for object array[%d]",
dst_pos, d->length());
} else {
ss.print("arraycopy: length %d is negative", length);
}
THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
}
// Check if the ranges are valid
if ((((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) ||
(((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length())) {
// Pass specific exception reason.
ResourceMark rm(THREAD);
stringStream ss;
if (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) {
ss.print("arraycopy: last source index %u out of bounds for object array[%d]",
(unsigned int) length + (unsigned int) src_pos, s->length());
} else {
ss.print("arraycopy: last destination index %u out of bounds for object array[%d]",
(unsigned int) length + (unsigned int) dst_pos, d->length());
}
THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
}
// Special case. Boundary cases must be checked first
// This allows the following call: copy_array(s, s.length(), d.length(), 0).
// This is correct, since the position is supposed to be an 'in between point', i.e., s.length(),
// points to the right of the last element.
if (length==0) {
return;
}
if (UseCompressedOops) {
size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(src_pos);
size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(dst_pos);
assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(s, src_offset, NULL) ==
objArrayOop(s)->obj_at_addr<narrowOop>(src_pos), "sanity");
assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(d, dst_offset, NULL) ==
objArrayOop(d)->obj_at_addr<narrowOop>(dst_pos), "sanity");
do_copy(s, src_offset, d, dst_offset, length, CHECK);
} else {
size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(src_pos);
size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(dst_pos);
assert(arrayOopDesc::obj_offset_to_raw<oop>(s, src_offset, NULL) ==
objArrayOop(s)->obj_at_addr<oop>(src_pos), "sanity");
assert(arrayOopDesc::obj_offset_to_raw<oop>(d, dst_offset, NULL) ==
objArrayOop(d)->obj_at_addr<oop>(dst_pos), "sanity");
do_copy(s, src_offset, d, dst_offset, length, CHECK);
}
}
(gdb) bt
#0 Copy::conjoint_oops_atomic (count=6, to=0x62a434ee8, from=0x62a42f220) at /home/dai/jdk/src/hotspot/share/utilities/copy.hpp:164
#1 AccessInternal::arraycopy_conjoint_oops (src=0x62a42f220, dst=0x62a434ee8, length=6) at /home/dai/jdk/src/hotspot/share/oops/accessBackend.cpp:94
#2 0x00007ffff7067317 in RawAccessBarrierArrayCopy::arraycopy<18112614ul, narrowOop> (length=6, dst_raw=<optimized out>, dst_offset_in_bytes=0, dst_obj=..., src_raw=0x62a42f220, src_offset_in_bytes=0,
src_obj=...) at /home/dai/jdk/src/hotspot/share/oops/accessBackend.inline.hpp:270
#3 RawAccessBarrier<18112614ul>::arraycopy<narrowOop> (length=6, dst_raw=0x62a434ee8, dst_offset_in_bytes=0, dst_obj=..., src_raw=<optimized out>, src_offset_in_bytes=0, src_obj=...)
at /home/dai/jdk/src/hotspot/share/oops/accessBackend.inline.hpp:344
#4 RawAccessBarrier<18112614ul>::oop_arraycopy<narrowOop> (length=6, dst_raw=0x62a434ee8, dst_offset_in_bytes=0, dst_obj=..., src_raw=<optimized out>, src_offset_in_bytes=0, src_obj=...)
at /home/dai/jdk/src/hotspot/share/oops/accessBackend.inline.hpp:128
#5 ModRefBarrierSet::AccessBarrier<18112614ul, G1BarrierSet>::oop_arraycopy_in_heap<narrowOop> (length=6, dst_raw=0x62a434ee8, dst_offset_in_bytes=<optimized out>, dst_obj=...,
src_raw=<optimized out>, src_offset_in_bytes=<optimized out>, src_obj=...) at /home/dai/jdk/src/hotspot/share/gc/shared/modRefBarrierSet.inline.hpp:108
#6 AccessInternal::PostRuntimeDispatch<G1BarrierSet::AccessBarrier<18112614ul, G1BarrierSet>, (AccessInternal::BarrierType)8, 18112614ul>::oop_access_barrier<HeapWordImpl*> (src_obj=...,
src_offset_in_bytes=<optimized out>, src_raw=<optimized out>, dst_obj=..., dst_offset_in_bytes=<optimized out>, dst_raw=<optimized out>, length=6)
at /home/dai/jdk/src/hotspot/share/oops/access.inline.hpp:142
#7 0x00007ffff7063f43 in AccessInternal::RuntimeDispatch<18112582ul, HeapWordImpl*, (AccessInternal::BarrierType)8>::arraycopy_init (src_obj=..., src_offset_in_bytes=16, src_raw=0x0, dst_obj=...,
dst_offset_in_bytes=<optimized out>, dst_raw=<optimized out>, length=<optimized out>) at /home/dai/jdk/src/hotspot/share/oops/access.inline.hpp:339
#8 0x00007ffff7061a0e in AccessInternal::RuntimeDispatch<18112582ul, HeapWordImpl*, (AccessInternal::BarrierType)8>::arraycopy (length=<optimized out>, dst_raw=<optimized out>,
dst_offset_in_bytes=<optimized out>, dst_obj=..., src_raw=<optimized out>, src_offset_in_bytes=<optimized out>, src_obj=...) at /home/dai/jdk/src/hotspot/share/oops/accessBackend.hpp:554
#9 AccessInternal::PreRuntimeDispatch::arraycopy<18112582ul, HeapWordImpl*> (length=<optimized out>, dst_raw=<optimized out>, dst_offset_in_bytes=<optimized out>, dst_obj=..., src_raw=<optimized out>,
src_offset_in_bytes=<optimized out>, src_obj=...) at /home/dai/jdk/src/hotspot/share/oops/accessBackend.hpp:907
#10 AccessInternal::arraycopy_reduce_types<18112580ul> (length=<optimized out>, dst_raw=<optimized out>, dst_offset_in_bytes=<optimized out>, dst_obj=..., src_raw=<optimized out>,
src_offset_in_bytes=<optimized out>, src_obj=...) at /home/dai/jdk/src/hotspot/share/oops/accessBackend.hpp:1054
#11 AccessInternal::arraycopy<18087940ul, HeapWordImpl*> (length=<optimized out>, dst_raw=<optimized out>, dst_offset_in_bytes=<optimized out>, dst_obj=..., src_raw=<optimized out>,
src_offset_in_bytes=<optimized out>, src_obj=...) at /home/dai/jdk/src/hotspot/share/oops/accessBackend.hpp:1208
#12 Access<18087936ul>::oop_arraycopy<HeapWordImpl*> (length=<optimized out>, dst_raw=<optimized out>, dst_offset_in_bytes=<optimized out>, dst_obj=..., src_raw=<optimized out>,
src_offset_in_bytes=<optimized out>, src_obj=...) at /home/dai/jdk/src/hotspot/share/oops/access.hpp:137
#13 ArrayAccess<16777216ul>::oop_arraycopy (length=<optimized out>, dst_offset_in_bytes=<optimized out>, dst_obj=..., src_offset_in_bytes=<optimized out>, src_obj=...)
at /home/dai/jdk/src/hotspot/share/oops/access.hpp:323
#14 ObjArrayKlass::do_copy (this=this@entry=0x800058a00, s=..., src_offset=src_offset@entry=16, d=..., dst_offset=dst_offset@entry=16, length=length@entry=6, __the_thread__=0x7ffff0028f20)
at /home/dai/jdk/src/hotspot/share/oops/objArrayKlass.cpp:213
#15 0x00007ffff7062e33 in ObjArrayKlass::copy_array (this=0x800058a00, s=..., src_pos=<optimized out>, d=..., dst_pos=<optimized out>, length=6, __the_thread__=0x7ffff0028f20)
at /home/dai/jdk/src/hotspot/share/oops/oopsHierarchy.hpp:85
#16 0x00007ffff6b2d75f in JVM_ArrayCopy (env=<optimized out>, ignored=<optimized out>, src=<optimized out>, src_pos=0, dst=<optimized out>, dst_pos=0, length=6)
at /home/dai/jdk/src/hotspot/share/prims/jvm.cpp:298
x86
的汇编代码如下src/hotspot/os_cpu/linux_x86/linux_x86_64.S
# Support for void Copy::arrayof_conjoint_jlongs(jlong* from,
# jlong* to,
# size_t count)
# Equivalent to
# conjoint_jlongs_atomic
# arrayof_conjoint_oops
# conjoint_oops_atomic
#
# rdi - from
# rsi - to
# rdx - count, treated as ssize_t
#
.p2align 4,,15
.type _Copy_arrayof_conjoint_jlongs,@function
.type _Copy_conjoint_jlongs_atomic,@function
_Copy_arrayof_conjoint_jlongs:
_Copy_conjoint_jlongs_atomic:
cmpq %rdi,%rsi
leaq -8(%rdi,%rdx,8),%rax # from + count*8 - 8
jbe acl_CopyRight
cmpq %rax,%rsi
jbe acl_CopyLeft
acl_CopyRight:
leaq -8(%rsi,%rdx,8),%rcx # to + count*8 - 8
negq %rdx
jmp 3f
1: movq 8(%rax,%rdx,8),%rsi
movq %rsi,8(%rcx,%rdx,8)
addq $1,%rdx
jnz 1b
ret
.p2align 4,,15
2: 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)
3: addq $4,%rdx
jle 2b
subq $4,%rdx
jl 1b
ret
4: movq -8(%rdi,%rdx,8),%rcx
movq %rcx,-8(%rsi,%rdx,8)
subq $1,%rdx
jnz 4b
ret
.p2align 4,,15
5: 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)
acl_CopyLeft:
subq $4,%rdx
jge 5b
addq $4,%rdx
jg 4b
ret
这里的文件jz
jne
是相对段的偏移 , 然后试试编译成字节码之后看效果
这里的as
是将汇编代码编译成二进制代码
$ as src/hotspot/os_cpu/linux_x86/linux_x86_64.S
$ objdump -S a.out
a.out: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <SpinPause>:
0: f3 90 pause
2: 48 c7 c0 01 00 00 00 mov $0x1,%rax
9: c3 ret
a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
0000000000000010 <_Copy_arrayof_conjoint_bytes>:
10: 49 89 d0 mov %rdx,%r8
13: 48 c1 ea 03 shr $0x3,%rdx
17: 48 39 fe cmp %rdi,%rsi
1a: 4a 8d 44 07 ff lea -0x1(%rdi,%r8,1),%rax
1f: 76 09 jbe 2a <acb_CopyRight>
21: 48 39 c6 cmp %rax,%rsi
24: 0f 86 9e 00 00 00 jbe c8 <acb_CopyLeft>
000000000000002a <acb_CopyRight>:
2a: 48 8d 44 d7 f8 lea -0x8(%rdi,%rdx,8),%rax
2f: 48 8d 4c d6 f8 lea -0x8(%rsi,%rdx,8),%rcx
34: 48 f7 da neg %rdx
37: eb 7d jmp b6 <acb_CopyRight+0x8c>
39: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
40: 48 8b 74 d0 08 mov 0x8(%rax,%rdx,8),%rsi
45: 48 89 74 d1 08 mov %rsi,0x8(%rcx,%rdx,8)
4a: 48 83 c2 01 add $0x1,%rdx
4e: 75 f0 jne 40 <acb_CopyRight+0x16>
50: 49 f7 c0 04 00 00 00 test $0x4,%r8
57: 74 0e je 67 <acb_CopyRight+0x3d>
59: 8b 70 08 mov 0x8(%rax),%esi
5c: 89 71 08 mov %esi,0x8(%rcx)
5f: 48 83 c0 04 add $0x4,%rax
63: 48 83 c1 04 add $0x4,%rcx
67: 49 f7 c0 02 00 00 00 test $0x2,%r8
6e: 74 0c je 7c <acb_CopyRight+0x52>
70: 66 8b 70 08 mov 0x8(%rax),%si
74: 66 89 71 08 mov %si,0x8(%rcx)
78: 48 83 c1 02 add $0x2,%rcx
7c: 49 f7 c0 01 00 00 00 test $0x1,%r8
83: 74 08 je 8d <acb_CopyRight+0x63>
85: 42 8a 44 07 ff mov -0x1(%rdi,%r8,1),%al
8a: 88 41 08 mov %al,0x8(%rcx)
8d: c3 ret
8e: 66 90 xchg %ax,%ax
90: 48 8b 74 d0 e8 mov -0x18(%rax,%rdx,8),%rsi
95: 48 89 74 d1 e8 mov %rsi,-0x18(%rcx,%rdx,8)
9a: 48 8b 74 d0 f0 mov -0x10(%rax,%rdx,8),%rsi
9f: 48 89 74 d1 f0 mov %rsi,-0x10(%rcx,%rdx,8)
a4: 48 8b 74 d0 f8 mov -0x8(%rax,%rdx,8),%rsi
a9: 48 89 74 d1 f8 mov %rsi,-0x8(%rcx,%rdx,8)
ae: 48 8b 34 d0 mov (%rax,%rdx,8),%rsi
b2: 48 89 34 d1 mov %rsi,(%rcx,%rdx,8)
b6: 48 83 c2 04 add $0x4,%rdx
ba: 7e d4 jle 90 <acb_CopyRight+0x66>
bc: 48 83 ea 04 sub $0x4,%rdx
c0: 0f 8c 7a ff ff ff jl 40 <acb_CopyRight+0x16>
c6: eb 88 jmp 50 <acb_CopyRight+0x26>
00000000000000c8 <acb_CopyLeft>:
c8: 49 f7 c0 01 00 00 00 test $0x1,%r8
cf: 74 0e je df <acb_CopyLeft+0x17>
d1: 42 8a 4c 07 ff mov -0x1(%rdi,%r8,1),%cl
d6: 42 88 4c 06 ff mov %cl,-0x1(%rsi,%r8,1)
db: 49 83 e8 01 sub $0x1,%r8
df: 49 f7 c0 02 00 00 00 test $0x2,%r8
e6: 74 0c je f4 <acb_CopyLeft+0x2c>
e8: 66 42 8b 4c 07 fe mov -0x2(%rdi,%r8,1),%cx
ee: 66 42 89 4c 06 fe mov %cx,-0x2(%rsi,%r8,1)
f4: 49 f7 c0 04 00 00 00 test $0x4,%r8
fb: 74 59 je 156 <acb_CopyLeft+0x8e>
fd: 8b 0c d7 mov (%rdi,%rdx,8),%ecx
100: 89 0c d6 mov %ecx,(%rsi,%rdx,8)
103: eb 51 jmp 156 <acb_CopyLeft+0x8e>
105: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
10c: 00 00 00 00
110: 48 8b 4c d7 f8 mov -0x8(%rdi,%rdx,8),%rcx
115: 48 89 4c d6 f8 mov %rcx,-0x8(%rsi,%rdx,8)
11a: 48 83 ea 01 sub $0x1,%rdx
11e: 75 f0 jne 110 <acb_CopyLeft+0x48>
120: c3 ret
121: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
128: 00 00 00 00
12c: 0f 1f 40 00 nopl 0x0(%rax)
130: 48 8b 4c d7 18 mov 0x18(%rdi,%rdx,8),%rcx
135: 48 89 4c d6 18 mov %rcx,0x18(%rsi,%rdx,8)
13a: 48 8b 4c d7 10 mov 0x10(%rdi,%rdx,8),%rcx
13f: 48 89 4c d6 10 mov %rcx,0x10(%rsi,%rdx,8)
144: 48 8b 4c d7 08 mov 0x8(%rdi,%rdx,8),%rcx
149: 48 89 4c d6 08 mov %rcx,0x8(%rsi,%rdx,8)
14e: 48 8b 0c d7 mov (%rdi,%rdx,8),%rcx
152: 48 89 0c d6 mov %rcx,(%rsi,%rdx,8)
156: 48 83 ea 04 sub $0x4,%rdx
15a: 7d d4 jge 130 <acb_CopyLeft+0x68>
15c: 48 83 c2 04 add $0x4,%rdx
160: 7f ae jg 110 <acb_CopyLeft+0x48>
162: c3 ret
163: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
16a: 00 00 00 00
16e: 66 90 xchg %ax,%ax
0000000000000170 <_Copy_arrayof_conjoint_jshorts>:
170: 49 89 d0 mov %rdx,%r8
173: 48 c1 ea 02 shr $0x2,%rdx
177: 48 39 fe cmp %rdi,%rsi
17a: 4a 8d 44 47 fe lea -0x2(%rdi,%r8,2),%rax
17f: 76 05 jbe 186 <acs_CopyRight>
181: 48 39 c6 cmp %rax,%rsi
184: 76 7e jbe 204 <acs_CopyLeft>
0000000000000186 <acs_CopyRight>:
186: 48 8d 44 d7 f8 lea -0x8(%rdi,%rdx,8),%rax
18b: 48 8d 4c d6 f8 lea -0x8(%rsi,%rdx,8),%rcx
190: 48 f7 da neg %rdx
193: eb 61 jmp 1f6 <acs_CopyRight+0x70>
195: 48 8b 74 d0 08 mov 0x8(%rax,%rdx,8),%rsi
19a: 48 89 74 d1 08 mov %rsi,0x8(%rcx,%rdx,8)
19f: 48 83 c2 01 add $0x1,%rdx
1a3: 75 f0 jne 195 <acs_CopyRight+0xf>
1a5: 49 f7 c0 02 00 00 00 test $0x2,%r8
1ac: 74 0a je 1b8 <acs_CopyRight+0x32>
1ae: 8b 70 08 mov 0x8(%rax),%esi
1b1: 89 71 08 mov %esi,0x8(%rcx)
1b4: 48 83 c1 04 add $0x4,%rcx
1b8: 49 f7 c0 01 00 00 00 test $0x1,%r8
1bf: 74 0a je 1cb <acs_CopyRight+0x45>
1c1: 66 42 8b 74 47 fe mov -0x2(%rdi,%r8,2),%si
1c7: 66 89 71 08 mov %si,0x8(%rcx)
1cb: c3 ret
1cc: 0f 1f 40 00 nopl 0x0(%rax)
1d0: 48 8b 74 d0 e8 mov -0x18(%rax,%rdx,8),%rsi
1d5: 48 89 74 d1 e8 mov %rsi,-0x18(%rcx,%rdx,8)
1da: 48 8b 74 d0 f0 mov -0x10(%rax,%rdx,8),%rsi
1df: 48 89 74 d1 f0 mov %rsi,-0x10(%rcx,%rdx,8)
1e4: 48 8b 74 d0 f8 mov -0x8(%rax,%rdx,8),%rsi
1e9: 48 89 74 d1 f8 mov %rsi,-0x8(%rcx,%rdx,8)
1ee: 48 8b 34 d0 mov (%rax,%rdx,8),%rsi
1f2: 48 89 34 d1 mov %rsi,(%rcx,%rdx,8)
1f6: 48 83 c2 04 add $0x4,%rdx
1fa: 7e d4 jle 1d0 <acs_CopyRight+0x4a>
1fc: 48 83 ea 04 sub $0x4,%rdx
200: 7c 93 jl 195 <acs_CopyRight+0xf>
202: eb a1 jmp 1a5 <acs_CopyRight+0x1f>
0000000000000204 <acs_CopyLeft>:
204: 49 f7 c0 01 00 00 00 test $0x1,%r8
20b: 74 0c je 219 <acs_CopyLeft+0x15>
20d: 66 42 8b 4c 47 fe mov -0x2(%rdi,%r8,2),%cx
213: 66 42 89 4c 46 fe mov %cx,-0x2(%rsi,%r8,2)
219: 49 f7 c0 02 00 00 00 test $0x2,%r8
220: 74 44 je 266 <acs_CopyLeft+0x62>
222: 8b 0c d7 mov (%rdi,%rdx,8),%ecx
225: 89 0c d6 mov %ecx,(%rsi,%rdx,8)
228: eb 3c jmp 266 <acs_CopyLeft+0x62>
22a: 48 8b 4c d7 f8 mov -0x8(%rdi,%rdx,8),%rcx
22f: 48 89 4c d6 f8 mov %rcx,-0x8(%rsi,%rdx,8)
234: 48 83 ea 01 sub $0x1,%rdx
238: 75 f0 jne 22a <acs_CopyLeft+0x26>
23a: c3 ret
23b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
240: 48 8b 4c d7 18 mov 0x18(%rdi,%rdx,8),%rcx
245: 48 89 4c d6 18 mov %rcx,0x18(%rsi,%rdx,8)
24a: 48 8b 4c d7 10 mov 0x10(%rdi,%rdx,8),%rcx
24f: 48 89 4c d6 10 mov %rcx,0x10(%rsi,%rdx,8)
254: 48 8b 4c d7 08 mov 0x8(%rdi,%rdx,8),%rcx
259: 48 89 4c d6 08 mov %rcx,0x8(%rsi,%rdx,8)
25e: 48 8b 0c d7 mov (%rdi,%rdx,8),%rcx
262: 48 89 0c d6 mov %rcx,(%rsi,%rdx,8)
266: 48 83 ea 04 sub $0x4,%rdx
26a: 7d d4 jge 240 <acs_CopyLeft+0x3c>
26c: 48 83 c2 04 add $0x4,%rdx
270: 7f b8 jg 22a <acs_CopyLeft+0x26>
272: c3 ret
273: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
27a: 00 00 00 00
27e: 66 90 xchg %ax,%ax
0000000000000280 <_Copy_arrayof_conjoint_jints>:
280: 49 89 d0 mov %rdx,%r8
283: 48 d1 ea shr %rdx
286: 48 39 fe cmp %rdi,%rsi
289: 4a 8d 44 87 fc lea -0x4(%rdi,%r8,4),%rax
28e: 76 05 jbe 295 <aci_CopyRight>
290: 48 39 c6 cmp %rax,%rsi
293: 76 6f jbe 304 <aci_CopyLeft>
0000000000000295 <aci_CopyRight>:
295: 48 8d 44 d7 f8 lea -0x8(%rdi,%rdx,8),%rax
29a: 48 8d 4c d6 f8 lea -0x8(%rsi,%rdx,8),%rcx
29f: 48 f7 da neg %rdx
2a2: eb 52 jmp 2f6 <aci_CopyRight+0x61>
2a4: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
2ab: 00 00 00 00
2af: 90 nop
2b0: 48 8b 74 d0 08 mov 0x8(%rax,%rdx,8),%rsi
2b5: 48 89 74 d1 08 mov %rsi,0x8(%rcx,%rdx,8)
2ba: 48 83 c2 01 add $0x1,%rdx
2be: 75 f0 jne 2b0 <aci_CopyRight+0x1b>
2c0: 49 f7 c0 01 00 00 00 test $0x1,%r8
2c7: 74 06 je 2cf <aci_CopyRight+0x3a>
2c9: 8b 70 08 mov 0x8(%rax),%esi
2cc: 89 71 08 mov %esi,0x8(%rcx)
2cf: c3 ret
2d0: 48 8b 74 d0 e8 mov -0x18(%rax,%rdx,8),%rsi
2d5: 48 89 74 d1 e8 mov %rsi,-0x18(%rcx,%rdx,8)
2da: 48 8b 74 d0 f0 mov -0x10(%rax,%rdx,8),%rsi
2df: 48 89 74 d1 f0 mov %rsi,-0x10(%rcx,%rdx,8)
2e4: 48 8b 74 d0 f8 mov -0x8(%rax,%rdx,8),%rsi
2e9: 48 89 74 d1 f8 mov %rsi,-0x8(%rcx,%rdx,8)
2ee: 48 8b 34 d0 mov (%rax,%rdx,8),%rsi
2f2: 48 89 34 d1 mov %rsi,(%rcx,%rdx,8)
2f6: 48 83 c2 04 add $0x4,%rdx
2fa: 7e d4 jle 2d0 <aci_CopyRight+0x3b>
2fc: 48 83 ea 04 sub $0x4,%rdx
300: 7c ae jl 2b0 <aci_CopyRight+0x1b>
302: eb bc jmp 2c0 <aci_CopyRight+0x2b>
0000000000000304 <aci_CopyLeft>:
304: 49 f7 c0 01 00 00 00 test $0x1,%r8
30b: 74 49 je 356 <aci_CopyLeft+0x52>
30d: 42 8b 4c 87 fc mov -0x4(%rdi,%r8,4),%ecx
312: 42 89 4c 86 fc mov %ecx,-0x4(%rsi,%r8,4)
317: eb 3d jmp 356 <aci_CopyLeft+0x52>
319: 48 8b 4c d7 f8 mov -0x8(%rdi,%rdx,8),%rcx
31e: 48 89 4c d6 f8 mov %rcx,-0x8(%rsi,%rdx,8)
323: 48 83 ea 01 sub $0x1,%rdx
327: 75 f0 jne 319 <aci_CopyLeft+0x15>
329: c3 ret
32a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
330: 48 8b 4c d7 18 mov 0x18(%rdi,%rdx,8),%rcx
335: 48 89 4c d6 18 mov %rcx,0x18(%rsi,%rdx,8)
33a: 48 8b 4c d7 10 mov 0x10(%rdi,%rdx,8),%rcx
33f: 48 89 4c d6 10 mov %rcx,0x10(%rsi,%rdx,8)
344: 48 8b 4c d7 08 mov 0x8(%rdi,%rdx,8),%rcx
349: 48 89 4c d6 08 mov %rcx,0x8(%rsi,%rdx,8)
34e: 48 8b 0c d7 mov (%rdi,%rdx,8),%rcx
352: 48 89 0c d6 mov %rcx,(%rsi,%rdx,8)
356: 48 83 ea 04 sub $0x4,%rdx
35a: 7d d4 jge 330 <aci_CopyLeft+0x2c>
35c: 48 83 c2 04 add $0x4,%rdx
360: 7f b7 jg 319 <aci_CopyLeft+0x15>
362: c3 ret
363: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
36a: 00 00 00 00
36e: 66 90 xchg %ax,%ax
0000000000000370 <_Copy_arrayof_conjoint_jlongs>:
370: 48 39 fe cmp %rdi,%rsi
373: 48 8d 44 d7 f8 lea -0x8(%rdi,%rdx,8),%rax
378: 76 09 jbe 383 <acl_CopyRight>
37a: 48 39 c6 cmp %rax,%rsi
37d: 0f 86 93 00 00 00 jbe 416 <acl_CopyLeft>
0000000000000383 <acl_CopyRight>:
383: 48 8d 4c d6 f8 lea -0x8(%rsi,%rdx,8),%rcx
388: 48 f7 da neg %rdx
38b: eb 39 jmp 3c6 <acl_CopyRight+0x43>
38d: 48 8b 74 d0 08 mov 0x8(%rax,%rdx,8),%rsi
392: 48 89 74 d1 08 mov %rsi,0x8(%rcx,%rdx,8)
397: 48 83 c2 01 add $0x1,%rdx
39b: 75 f0 jne 38d <acl_CopyRight+0xa>
39d: c3 ret
39e: 66 90 xchg %ax,%ax
3a0: 48 8b 74 d0 e8 mov -0x18(%rax,%rdx,8),%rsi
3a5: 48 89 74 d1 e8 mov %rsi,-0x18(%rcx,%rdx,8)
3aa: 48 8b 74 d0 f0 mov -0x10(%rax,%rdx,8),%rsi
3af: 48 89 74 d1 f0 mov %rsi,-0x10(%rcx,%rdx,8)
3b4: 48 8b 74 d0 f8 mov -0x8(%rax,%rdx,8),%rsi
3b9: 48 89 74 d1 f8 mov %rsi,-0x8(%rcx,%rdx,8)
3be: 48 8b 34 d0 mov (%rax,%rdx,8),%rsi
3c2: 48 89 34 d1 mov %rsi,(%rcx,%rdx,8)
3c6: 48 83 c2 04 add $0x4,%rdx
3ca: 7e d4 jle 3a0 <acl_CopyRight+0x1d>
3cc: 48 83 ea 04 sub $0x4,%rdx
3d0: 7c bb jl 38d <acl_CopyRight+0xa>
3d2: c3 ret
3d3: 48 8b 4c d7 f8 mov -0x8(%rdi,%rdx,8),%rcx
3d8: 48 89 4c d6 f8 mov %rcx,-0x8(%rsi,%rdx,8)
3dd: 48 83 ea 01 sub $0x1,%rdx
3e1: 75 f0 jne 3d3 <acl_CopyRight+0x50>
3e3: c3 ret
3e4: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
3eb: 00 00 00 00
3ef: 90 nop
3f0: 48 8b 4c d7 18 mov 0x18(%rdi,%rdx,8),%rcx
3f5: 48 89 4c d6 18 mov %rcx,0x18(%rsi,%rdx,8)
3fa: 48 8b 4c d7 10 mov 0x10(%rdi,%rdx,8),%rcx
3ff: 48 89 4c d6 10 mov %rcx,0x10(%rsi,%rdx,8)
404: 48 8b 4c d7 08 mov 0x8(%rdi,%rdx,8),%rcx
409: 48 89 4c d6 08 mov %rcx,0x8(%rsi,%rdx,8)
40e: 48 8b 0c d7 mov (%rdi,%rdx,8),%rcx
412: 48 89 0c d6 mov %rcx,(%rsi,%rdx,8)
0000000000000416 <acl_CopyLeft>:
416: 48 83 ea 04 sub $0x4,%rdx
41a: 7d d4 jge 3f0 <acl_CopyRight+0x6d>
41c: 48 83 c2 04 add $0x4,%rdx
420: 7f b1 jg 3d3 <acl_CopyRight+0x50>
422: c3 ret
总结
arrays 包含一堆变量.变量有两种值:primitive
值 , reference
值.
所以copyarrays
复制的是变量,也就是复制的是引用
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array. A subsequence of array components are copied from the source array referenced by src to the destination array referenced by dest. The number of components copied is equal to the length argument. The components at positions srcPos through srcPos+length-1 in the source array are copied into positions destPos through destPos+length-1, respectively, of the destination array.