Page MenuHomeFreeBSD

Various rearrangements to make memmove a first class citizen
ClosedPublic

Authored by imp on May 10 2018, 12:38 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 18 2024, 10:39 PM
Unknown Object (File)
Mar 18 2024, 10:35 PM
Unknown Object (File)
Feb 11 2024, 2:41 PM
Unknown Object (File)
Jan 14 2024, 7:20 AM
Unknown Object (File)
Jan 6 2024, 6:47 PM
Unknown Object (File)
Jan 1 2024, 5:22 AM
Unknown Object (File)
Nov 26 2023, 5:33 PM
Unknown Object (File)
Nov 26 2023, 5:26 PM
Subscribers

Details

Summary

These are several commits that will be pushed separately

Move MI-ish bcopy routine to libkern

riscv and powerpc have nearly identical bcopy.c that's
supposed to be mostly MI. Move it to the MI libkern.

Simplify things a little

Rather than include a copy for memmove to call bcopy to call memcpy
(which handles overlapping copies), make memmove a strong reference to
memcpy to save the two calls.

Make memmove an alias for memcpy

memcpy was an alias for bcopy with arg swap. This code handles
overlapping copies, so making memmove an alias is safe. We can
eliminate the call from libkern's memmove to this bcopy as a result.

Define memmove and make bcopy alt entry point

Make a memmove entry point just before bcopy and have it swap its args
before continuing into the body of bcopy. Adjust the returns to return
dst (original %o0 swapped to %o1) from both entry points. bcopy users
will ignore them. Since these are in the branch delay slot, it should
take no additional time. I use %o6 for this rather than just move %o1
back to %o2 at the end since my sparc64 assembler knowledge is weak.
Also eliminate wrapper call from memmove to bcopy.

Remove unused bcopyb.

Make memmove and bcopy share code

Make memmove the primary interface, but have bcopy be an alternative
entry point that jumps into memmove. This will slightly pessimize
bcopy calls, but those are about to get much rarer. Return dst always,
but it will be ignored by bcopy callers. We can remove just the alt
entry point if we ever remove bcopy entirely.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Update to actually remove libkern/mmemmove.c

This revision was not accepted when it landed; it landed in state Needs Review.May 10 2018, 2:31 AM
This revision was automatically updated to reflect the committed changes.

Update after committing the low-risk deck-chair motion.

marius requested changes to this revision.May 12 2018, 11:28 PM

Generally looks good for the sparc64 part, for consistency with the existing style it would be preferable to use the next free input register after those used for the arguments for the newly needed temporary register, i. e. o3 instead of o6, though.
However, given that the idea is to make "memmove a first class citizen", it seems backwards to inflict memmove with extra MOVs, and bcopy likely never can actually go away. So I'd rather convert the existing bcopy implementation into a _MEMMOVE macro similar to the existing _MEM{CPY,SET} ones (but without the ASI support of these latter) and use _MEMMOVE to implement both bcopy and memmove, which could be done in a separate change, though.

This revision now requires changes to proceed.May 12 2018, 11:28 PM

I've considered Marius' suggestion. I reject it. memmove is now a first class citizen. If you'd like to make it even better, you are welcome to do so after this commit.

This revision was not accepted when it landed; it landed in state Needs Revision.May 24 2018, 9:11 PM
This revision was automatically updated to reflect the committed changes.