On Wed., 18 Mar. 2020, 3:24 am Skip Montanaro, <skip.montan...@gmail.com>
wrote:

> (Apologies if you're seeing this twice. I first posted to the
> discourse instance.)
>
> I first worked on a register-based virtual machine in the 1.5.2
> timeframe. That was before PEP 227 (closures) landed. Prior to that,
> local variables and the stack were contiguous in the f_localsplus
> array. Based on a comment at the time from Tim Peters (which I recall
> but can no longer find), the number of required registers won’t be any
> greater than the maximum extent of the stack. (It makes sense, and
> worked for me at the time.) That allowed me to repurpose the stack
> space as my registers and treat the full f_localsplus array as a
> single large “register file,” eliminating LOAD_FAST_REG and
> STORE_FAST_REG instructions completely, which I believe was a major
> win.
>
> I want to rearrange the current f_localsplus to make locals and stack
> neighbors again. My first look at the code suggested there is no good
> reason it can’t be done, but figured Jeremy Hylton must have had a
> good reason to prefer the current layout which places cells and frees
> in the middle.
>
> While the necessary changes didn’t look extensive, they did look a bit
> tedious to get right, which I have confirmed. My first attempt to
> reorganize f_localsplus from locals/cells/frees/stack to
> locals/stack/cells/frees has been an abysmal failure. I’ve found a
> couple mistakes and corrected them. Implementing those corrections
> caused the types of failures to change (convincing me they were
> necessary), but did not eliminate them entirely (so, necessary, but
> not sufficient). I’ve clearly missed something. I’m also fairly
> ignorant about recent changes to the language (big understatement), so
> thought that before going any further, I would see if anyone with
> better current knowledge of frame objects knew of a reason why my
> desired layout change wouldn’t work.
>

I'm not aware of any fundamental reason it wouldn't work, but I would
expect the FastToLocals and LocalsToFast functions to require some
non-trivial adjustments to cope with the layout change (it's been a while
since I looked at the unmodified version of that code, but my recollection
is that it expects the locals and cell variables to be next to each other
so it can iterate over them as a single C array, rather than looping over
them separately).

Cheers,
Nick.


>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/ARP2K7VQQTQG5CWFFBYAEY4LFYOMO5LW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to