[Vm-dev] Primitive replaceFrom:to:with:startingAt: in the JIT

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Thu Dec 28 08:10:12 UTC 2017


2017-12-28 9:01 GMT+01:00 Clément Bera <bera.clement at gmail.com>:

>
>
>
> On Thu, Dec 28, 2017 at 12:03 AM, tim Rowledge <tim at rowledge.org> wrote:
>
>>
>>
>> > On 27-12-2017, at 2:56 PM, Clément Bera <bera.clement at gmail.com> wrote:
>> >
>> >
>> > Assembling a word when reads are not aligned with the writes seemed
>> tedious - not sure if that's the best time invested/speed-up ratio. One
>> could experiment.
>> >
>> It’s just an  8bpp bitblt on a single line. We kinda-sorta have code for
>> that lying around.
>>
>> How about handling any simple cases you can come up with and failing to
>> the (usually) intrinsic memcpy() ? Take advantage of those 4 people’s
>> months of work!
>>
>
> We can't do that. Unfortunately our primitives allow things that memcopy
> does not such as:
>
> array := ByteArray new: 1000.
> array at: 1 put: 255.
> array replaceFrom: 2 to: 500 with: array startingAt: 1.
> array at: 501 put: 42.
> array replaceFrom: 502 to: 1000 with: array startingAt: 501.
>
> Or we detect aliasing and fall back to C code if there is aliasing ...
>
> ...
>
>

I don't much like the current implementation in case of aliasing...

But note that this mechanism is effectively used by (g)zip implementation
in Squeak/Pharo.
Using memcpy would be relying on undefined behavior.
Using memmove would lead to a different result.


>> tim
>> --
>> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
>> All programmers are playwrights and all computers are lousy actors.
>>
>>
>>
>
>
> --
> Clément Béra
> Pharo consortium engineer
> https://clementbera.wordpress.com/
> Bâtiment B 40, avenue Halley 59650 Villeneuve d'Ascq
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20171228/8ac62d0f/attachment.html>


More information about the Vm-dev mailing list