Since
fpc_dynarray_setlength is an internal compiler intrinsic it does not make sense to try and call it directly from assembler.
Since
dynamic arrays also
need RTTI generated, the compiler produces already near optimal code(X86_64):
# [8] setlength(p,5);
movq $5,-8(%rbp)
leaq -8(%rbp),%r9
leaq RTTI_$P$REDIRECTS_$$_TPOINTERS(%rip),%rdx
leaq U_$P$REDIRECTS_$$_P(%rip),%rcx
movq $1,%r8
call fpc_dynarray_setlength
I would take @runewalsh advice.
fpc_dynarray_setlength is not accessible outside of the compiler itself, because it is not exported.
Compilerprocs seldom are.
fpc_dynarray_setlength does three things very efficiently:
- It sets up the data for the managed type: length/size and refcount
- It (re-) allocates memory
- performs a copy if needed (if the size grows)
Because of that, there is little if any speed to gain anyway. Any bottleneck would be in fpc_dynarray_setlength.
You should know how to
read the compiler sources too if you want to use assembler efficiently...
There is no reason to document all that apart from in the sources.
Any perceived assembler shortcuts may break your code in any next generation of the compiler.
Since all that is implementation detail. (And not exported for that reason!)