<div>On Tue, 22 Dec 2020 at 9:35 am, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br></div><div style="background-color:rgba(0,0,0,0)!important;border-color:rgb(0,0,0)!important;color:rgb(0,0,0)!important"><div class="gmail_quote" style="background-color:rgba(0,0,0,0)!important;border-color:rgb(0,0,0)!important;color:rgb(0,0,0)!important"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">Hi Fabio,<br>
<br>
> On Dec 20, 2020, at 1:27 PM, Fabio Niephaus <<a href="mailto:lists@fniephaus.com" target="_blank">lists@fniephaus.com</a>> wrote:<br>
> <br>
> Hi Eliot,<br>
> <br>
>> On Tue, Dec 15, 2020 at 3:06 AM Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>> wrote:<br>
>> <br>
>> Hi Fabio,<br>
>> <br>
>>> On Mon, Dec 14, 2020 at 1:33 PM Fabio Niephaus <<a href="mailto:lists@fniephaus.com" target="_blank">lists@fniephaus.com</a>> wrote:<br>
>>> <br>
>>> Hi all,<br>
>>> <br>
>>> While digging through the implementation of FullBlockClosure with<br>
>>> Hernan, we were wondering about full closures that ignore their<br>
>>> outerContext. We noticed that the following method has two senders:<br>
>>> EncoderForSistaV1>>#genPushFullClosure:numCopied:receiverOnStack:ignoreOuterContext:<br>
>>> <br>
>>> One of them seems to be the only one in use, and it's passing in false<br>
>>> as defaults for both receiverOnstack and ignoreOuterContext. The other<br>
>>> sender (BytecodeEncoder>>#sizePushFullClosure:numCopied:receiverOnStack:ignoreOuterContext:),<br>
>>> in turn, doesn't seem to have any further senders.<br>
>>> <br>
>>> Unless we missed something, it looks like the outerContext will never<br>
>>> be ignored at the moment. Similarly, the receiver is never on the<br>
>>> stack. Is this something only Scorch can do or is this just "not yet<br>
>>> implemented"?<br>
>>> <br>
>>> When can the outerContext be ignored?<br>
>> <br>
>> <br>
>> When the Sista optimizer determines that it isn't needed. i.e. this option is nover used in vanilla code but exists for an optimizing compiler to avoid the overhead in cases where it wants to avoid inlining but knows there is no real suspension point during some evaluation.  Now, whether we'll ever use this facility I can't say, but it was certainly in Clément's mind to do so at some point.<br>
>>> <br>
> <br>
> Ok, thanks for the info!<br>
> <br>
>>> When does it make sense to pop the receiver from the stack?<br>
>> <br>
>> <br>
>> The point isn't really to pop the receiver from the stack.  The point is to be able to take the closures receiver form the stack rather than it being implicitly the receiver of the current method.  If closure creation gets inlined by the optimizer then there will be potentially a mismatch between the current method's receiver and an inlined closure's receiver, which necessitates having the facility to specify a distinct receiver.<br>
>> <br>
> <br>
> Makes sense, thanks!<br>
> <br>
>> <br>
>>> <br>
>>> And where can we find the latest version<br>
>>> of Scorch. Is it still the one at [1]?<br>
>> <br>
>> <br>
>> <a href="http://smalltalkhub.com/mc/ClementBera/Scorch/main" rel="noreferrer" target="_blank">http://smalltalkhub.com/mc/ClementBera/Scorch/main</a><br>
> <br>
> Oh, isn't smalltalkhub read-only these days?<br>
<br>
If it is then things need to move once time is found to work on the code again.<br>
<br>
> <br>
>> <br>
>> If you're interested in looking at Scorch I'm very interested in collaborating.  And there ius one significant modification to perform first which will make development much easier, and that is to restructure the interface between the optimizer and the image via mirrors, allowing the optimizer to be mated with an image being simulated, rather than having to be a full peer of the image it is optimizing.<br>
> <br>
> Since we turned on full closures and Sista in Squeak, I could no<br>
> longer use trunk images on top of TruffleSqueak. I finally decided to<br>
> bite the bullet and worked on support for both in the last two weeks.<br>
> It's not that I don't want to collaborate and help evolve Scorch (it's<br>
> a fascinating project!). It's just that I don't have the time to work<br>
> on any significant contributions in that direction. Nonetheless, I'd<br>
> love to see someone working on it again.<br>
<br>
Ah ok, makes sense.  Now you’ve implemented the Sista set I’m curious how you evaluate the design.</blockquote><div dir="auto"><br></div><div dir="auto">I've actually worked on another implementation for SqueakJS in the meantime (see [1]) ... here are some quick thoughts:</div><div dir="auto"><br></div><div dir="auto">- I like that bytecodes are ordered by the number of bytes they consume (1, 2, 3). This makes implementations a bit easier to read (e.g. looking up the number of bytes per bytecode is very simple).</div><div dir="auto"><br></div><div dir="auto" style="background-color:rgba(0,0,0,0)!important;border-color:rgb(0,0,0)!important;color:rgb(0,0,0)!important"><span>- I noticed that some parts are still unfinished and I couldn't always guess what the plan was. Bytecodes 0x52 and 0x5E, for example, take the extension bytes under consideration. Right now, however, they only do something if the corresponding extension is 0. That's a bit odd, but I'm guessing the plan was to add more controls...not sure which though. Extension bytes in general are a nice concept.</span></div><div dir="auto"><br></div><div dir="auto">- FullBlockClosures are very much in line with how language implementation frameworks (Truffle, RPython) imagine closures. It was therefore quite easy to support them in TruffleSqueak. However, and as I found out in this thread, the implementation is also unfinished. Right now, the outer context is never ignored, so the overhead is comparable to old closures. I thought the Squeak compiler would ignore the outer context if non-local returns are not present. Maybe that's something we should try out next?</div><div dir="auto"><br></div><div dir="auto">- In terms of performance, Sista makes almost no difference in TruffleSqueak. For tinyBenchmarks, the compiler output is even identical. Therefore, it seems the Graal compiler can optimise Sista just as good as the old bytecode set, which is an interesting result. I expect to observe the same when running with Scorch. The optimisations done by Scorch are probably quite similar to what Graal does, only on a much higher level and then Graal would only have less to do. The main difference though is that Scorch optimisations are persisted within the image, which could greatly improve warmup.</div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto">Fabio</div><div dir="auto"><br></div><div dir="auto">[1] <div><a href="https://github.com/codefrau/SqueakJS/blob/deaf0a5ca0b02d3dc9608fee6b7d9d544a4962da/vm.interpreter.js#L351">https://github.com/codefrau/SqueakJS/blob/deaf0a5ca0b02d3dc9608fee6b7d9d544a4962da/vm.interpreter.js#L351</a></div></div><div dir="auto"><br></div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)" dir="auto"><br>
<br>
Eliot<br>
_,,,^..^,,,_ (phone)<br>
<br>
> <br>
> Fabio<br>
> <br>
>>> <br>
>>> Cheers,<br>
>>> Fabio<br>
>>> <br>
>>> [1] <a href="https://github.com/clementbera/Scorch" rel="noreferrer" target="_blank">https://github.com/clementbera/Scorch</a><br>
>> <br>
>> <br>
>> _,,,^..^,,,_<br>
>> best, Eliot<br>
>> <br>
> <br>
<br>
</blockquote></div></div>