[squeak-dev] CompiledBlocks are fascinating

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Sun Apr 19 22:09:15 UTC 2020


Hi Eliot,


> This may be a return address.  If you ran this in the simulator you'd be able to see.  Also try running it on the StackInterpreter and see what you get.

Ah, this could be an explanation! I finally need to check out the VMMaker :-)
Wouldn't this be a memory leak vulnerability in the VM? Or don't we care about vulnerability issues in completely open systems such as Smalltalk at all?

> What do you mean by "translates the #pushRcvr: bytecodes to another class"?

Well, that's actually another issue. Since instance variable accesses are encoded into the bytecode by index, not by name, you cannot reuse the bytecodes for different kinds of objects:

c := Object newUniqueClassInstVars: 'foo bar' classInstVars: ''.
d := Object newUniqueClassInstVars: 'bar baz' classInstVars: ''.
c compile: 'bar ^ bar'.
o := c new.
p := d new.
o instVarNamed: 'bar' put: 42.
o bar. "42"
p instVarNamed: 'bar' put: 42.
p executeMethod: c >> #bar. "expected 42, but got nil"

You always need to recompile the methods first ... This makes it impossible to add instance variables to traits, for example.

Best,
Christoph

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Eliot Miranda <eliot.miranda at gmail.com>
Gesendet: Samstag, 18. April 2020 21:05 Uhr
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] CompiledBlocks are fascinating



On Sat, Apr 18, 2020 at 10:31 AM Thiede, Christoph <Christoph.Thiede at student.hpi.uni-potsdam.de<mailto:Christoph.Thiede at student.hpi.uni-potsdam.de>> wrote:

class := Object newSubclass.

class addSelector: #foo: withMethod: (

[:x | x squared * 2] method as: CompiledMethod).

class new foo: 3. "18"

And you can even debug it :D

[cid:1718ead4671f456b1e51]

This one is really crazy

class := Object newUniqueClassInstVars: 'state' classInstVars: ''.
class addSelector: #foo withMethod: (
[:x | gate] method as: CompiledMethod).
class new foo "-1.2045729113346377e-38"

What the ...? Am I accessing any private method literals here?

This may be a return address.  If you ran this in the simulator you'd be able to see.  Also try running it on the StackInterpreter and see what you get.




Then we only need a mechanism that translates the #pushRcvr: bytecodes to another class.

I don't see you jumping to the metacircular interpreter in the above.  What do you mean by "translates the #pushRcvr: bytecodes to another class"?


Best,

Christoph


--
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200419/e78fb007/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 1857 bytes
Desc: pastedImage.png
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200419/e78fb007/attachment.png>


More information about the Squeak-dev mailing list