[Vm-dev] ASM questions for tight loops
leves at caesar.elte.hu
Sat Jan 6 18:58:49 UTC 2018
On Sat, 6 Jan 2018, Clément Bera wrote:
>  Smalltalk code
> 1 to: (y - x + 1) do: [ :i |
> array2 at: y2 + i put: (array at: x + i) ].
This is not equal to
>  primitive call
> array2 replaceFrom: x to: y with: array startingAt: y2
Because for example the value at x in array will never be copied.
I suggest you compare the results with the original fallback code:
| index repOff |
repOff := y2 - x.
index := x - 1.
[(index := index + 1) <= y]
whileTrue: [self at: index put: (replacement at: repOff + index)]
I just ran some benchmarks, and the primitive was 19x faster than the
More information about the Vm-dev