[Vm-dev] empty blocks optimization

Florin Mateoc florin.mateoc at gmail.com
Sat Jan 11 06:42:55 UTC 2020


Hi,

I was thinking of implementing a relatively simple optimization for empty
blocks - there's something in the air about blocks lately :)

The compiler would create them as a new kind of literal (a subclass of
BlockClosure), so there would be no block creation at runtime. Even the
bytecodes for them would be simplified - it would be just a load literal.
As far as I can tell, this would also not require any VM or bytecode
changes.
I also don't think they would clash with the coming full block closures.

See attached to see what the new class definition would look like. By
employing Eliot's trick of re-using startpc, they can even return a non-nil
constant or other literals, and thus can even cover a little more than just
purely empty blocks. And we could also reuse these literals, there is no
point in creating multiple instances for [].
Given how often we use "at: aKey ifAbsent: []" or "detect: [:| ...] ifNone:
[]", I think it would be worth it, but let's see what you guys think.
Worst case, I'll just implement it in GraalSqueak :). Just kidding, I'll do
it in GraalSqueak anyway :)

Florin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20200111/2b61d114/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: EmptyBlockClosure.st
Type: application/octet-stream
Size: 6858 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20200111/2b61d114/attachment-0001.obj>


More information about the Vm-dev mailing list