develooper Front page | perl.perl5.porters | Postings from July 2014

jhi's libperl branch, freebsd memcmp

July 22, 2014 06:20
jhi's libperl branch, freebsd memcmp
Message ID:
Since jhi is offline on IRC ATM, this is a ML message. Things like 
memcmp, strlen, memset, memcpy can be inlined, there are dedicated x86 
instructions which literally are those 4 functions in 4 x86 opcode, read 
Visual C's inlining doc for ideas on things that are often inlined . There is no 
reliable way to know if they will or won't be inlined. UNLIKELY() or PGO 
can cause certain code blocks to be small (-Os, calls c lib func or 
inline version, depending on how many bytes of instructions it takes to 
do either) or fast (inlining time, or C lib call). Since on some CPUs, 
the fancy "string" instructions ( 
) are implemented in microcode as "backwards compatibility", and are 
slower than the longer in machine code bytes "modern" implementations 
that use "modern" instructions to the do same thing. Therefore some C 
compilers will always call the dedicated C functions, and not the 
inlined versions. Of course some compilers could also inline the long 
"modern" version of those functions.

The other design issue is, should something like memcpy be replaceable 
through the PLT on ELF platforms? Maybe you want to print a message to 
STDERR if the memcpy length is over 1 MB for example. If memcpy was 
inlined, now your C compiler is "broken" and isn't POSIX compatible. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About