[squeak-dev] modifying instance variable allocation
Thiede, Christoph
Christoph.Thiede at student.hpi.uni-potsdam.de
Wed May 4 17:05:53 UTC 2022
If performance is not an issue, you could also use code simulation to modify the way how instance variable are assigned. For that, you could use SimulationStudio and override Simulator>>#context:popIntoReceiverVariable:do: in a subclass.
Advantage: No need to modify the image and rewrite every bytecode.
Disadvantage: Significantly (!) slower.
In the past, there ByteSurgeon for bytecode rewriting ... But it seems to no longer work in present Squeak.
Best,
Christoph
________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel
Gesendet: Montag, 2. Mai 2022 14:23:59
An: squeak-dev
Betreff: Re: [squeak-dev] modifying instance variable allocation
It would be interesting to see a compiler (configuration) where you could disable some optimized byte codes to then generate the sends instead. Scoped per class just like #compilerClass already does. Maybe via #compilerPreferences to make it more user-friendly?
MySpecialObject class >> #compilerPreferences
^ #(
fastInstVarAccess false
fastClassAccess false "#class"
fastConditionals false "#ifTrue: #ifFalse: #ifNil: #ifNotNil:"
fastIntervalEnumeration false "#to:do:"
... )
Anyway, I presume that no such configurable option exists in Compiler/Encoder yet?
Best,
Marcel
Am 02.05.2022 07:42:41 schrieb Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>:
Hi Lauren,
Indeed, the VM is cheating, and for obvious efficiency reasons don't send the message instVarAt:. You would need to define a specific Compiler to encode the inst var access with other bytecode sequences.
Nicolas
Le lun. 2 mai 2022, 03:08, Lauren Pullen <drurowin at gmail.com<mailto:drurowin at gmail.com>> a écrit :
Hi list,
I'm trying to make an object that has special instance variable
allocation methods by overriding #instVarAt: and #instVarAt:put:, but it
isn't working.
In an inspector, the fields are presented as expected, but the
#pushRcvr: and #popIntoRcvr: bytecodes seem to use the basic behavior.
#instVarAt: and #instVarAt:put: aren't labeled 'No lookup.' like #== is,
but the VM bytecode evaluator doesn't use them for instance variable
access so the overridden the new behavior only works in the simulator...
which includes everything from inspectors to fileIn/Out and bytecode
simulators.
Is this something you can do? or are you required to use custom getter
and setter methods?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220504/f7dd8af5/attachment.html>
More information about the Squeak-dev
mailing list
|