<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body dir="auto">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Hi Eliot,</p>
<p><br>
</p>
<p>thank you for the fast feedback!</p>
<p><br>
</p>
<p>Here is just some other thing that currently goes wrong with primitiveNew and primitiveClass:</p>
<p><br>
</p>
<p><span>thisContext objectClass: Metaclass new new. "hangs"</span><br>
</p>
<p>Metaclass new new foo. "hangs"<br>
</p>
<p><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">Metaclass new new printString. "hangs"</span><br>
</p>
<p><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">thisContext object: Metaclass new new eqeq: nil. "true - works!"</span><br>
</p>
<p></p>
<p style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
Metaclass new new isNil. "false - works!"</p>
<p style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
<span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">In addition, primitiveBehaviorHash fails before the new behavior's
 format is set.</span><br>
</p>
<p style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
<br>
</p>
<p style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
I am trying to create a subclass in Sandbox and any of these effects are preventing me from running the instance creation in the custom simulator. I will need to investigate this more closely, but are you aware of any contract about the order of "special touches"
 that may or must be made to a new Behavior/Metaclass instance <span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">via</span><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"> the
 VM before it can be used arbitrarily? Without detailed knowledge about VMMaker, this is currently still a black box, and it would be awesome to improve the possibilities to exhaust these primitives from the image side. :-)</span></p>
<p style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
<span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><br>
</span></p>
<p style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
<span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">Best,</span></p>
<p style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
<span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">Christoph</span></p>
<p style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
<span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><br>
</span></p>
<p style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
<span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">PS: Not intending to sound pressing, nothing is urgent, but are you
 still having the different issues with execute primitives on your list that I have collected in <a href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2021-November/216937.html" class="OWAAutoLink" id="LPlnk716740" previewremoved="true">http://lists.squeakfoundation.org/pipermail/squeak-dev/2021-November/216937.html</a>?
 :-)</span></p>
<p></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Eliot Miranda <eliot.miranda@gmail.com><br>
<b>Gesendet:</b> Dienstag, 28. Dezember 2021 20:13:50<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> Re: [squeak-dev] primitiveClass infected after primitiveIdentityHash on wrong receiver</font>
<div> </div>
</div>
<div><br>
On Dec 28, 2021, at 9:02 AM, Christoph.Thiede@student.hpi.uni-potsdam.de wrote:<br>
<div dir="ltr">
<blockquote type="cite"><br>
</blockquote>
</div>
<blockquote type="cite">
<div dir="ltr">Hi Eliot, Hi all,<br>
<br>
the following snippet returns an unexpected result to me cross-platform (tested with 202112201228 on Win 21H1 and WSL/Ubuntu 18.04):<br>
<br>
<font color="#000000">    </font><font color="#000000">ProtoObject</font><font color="#000000">
</font><font color="#000080">tryPrimitive:</font><font color="#000000"> </font><font color="#800000">75</font><font color="#000000">
</font><font color="#000080">withArgs:</font><font color="#000000"> </font><font color="#000080">#</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">.</font><font color="#000000"><br>
    </font><font color="#800000">thisContext</font><font color="#000000"> </font>
<font color="#000080">objectClass:</font><font color="#000000"> </font><font color="#000000">ProtoObject</font><font color="#000000">
</font><font color="#000080">basicNew</font><font color="#000000">.</font><font color="#000000">
</font><font color="#008080">"nil"</font><br>
<br>
The example needs to be run in a fresh image. If primitiveBehaviorHash was sent to ProtoObject before, the bug does not occur:<br>
<br>
<font color="#000000">    </font><font color="#000000">ProtoObject</font><font color="#000000">
</font><font color="#000080">tryPrimitive:</font><font color="#000000"> </font><font color="#800000">175</font><font color="#000000">
</font><font color="#000080">withArgs:</font><font color="#000000"> </font><font color="#000080">#</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">.</font><font color="#000000"><br>
    </font><font color="#000000">ProtoObject</font><font color="#000000"> </font>
<font color="#000080">tryPrimitive:</font><font color="#000000"> </font><font color="#800000">75</font><font color="#000000">
</font><font color="#000080">withArgs:</font><font color="#000000"> </font><font color="#000080">#</font><font color="#000000">(</font><font color="#000000">)</font><font color="#000000">.</font><font color="#000000"><br>
    </font><font color="#800000">thisContext</font><font color="#000000"> </font>
<font color="#000080">objectClass:</font><font color="#000000"> </font><font color="#000000">ProtoObject</font><font color="#000000">
</font><font color="#000080">basicNew</font><font color="#000000">.</font><font color="#000000">
</font><font color="#008080">"ProtoObject"</font><br>
</div>
</blockquote>
<div><br>
</div>
Thanks, Christoph!  Very very nice!  Ouch.
<div><br>
<blockquote type="cite">
<div dir="ltr"><br>
I'm not sure whether this should be classified as a bug. </div>
</blockquote>
<div><br>
</div>
But it is :-)</div>
<div><br>
<blockquote type="cite">
<div dir="ltr">On the one hand, the name and the implementors of primitiveIdentityHash make pretty clear that one should not invoke it with a behavior. On the other hand, incidents like this make the usage of primitives extremely hard.<br>
I was writing a mirror primitive method that used primitiveIdentityHash in the first run and only falled back to primitiveBehaviorHash if the former failed [1]. Imagine how many hours it took me to trace a larger segfaulting test suite back to this unexpected
 behavior of primitiveClass. :-)<br>
In my expectation, primitiveIdentityHash should consequently fail for unappropriate receivers. However, I have fixed my mirror implementation now and only wanted to let you know about this observation.<br>
</div>
</blockquote>
<div><br>
</div>
The issue is how efficiently to determine that primitive 75 is being invoked on a behavior.  Luckily this determination doesn’t need to be made if the argument count is zero, so the common case is unaffected.</div>
<div><br>
</div>
<div>One style in HPS, the VisualWorks VM, is to look up a message via the method lookup class. So one would lookup #identityHash or #basicNew in the class of the argument, and if it bound to a method with primitive 175 or 70 respectively, then the argument
 is a behaviour, and the test is much cheaper if executed subsequently.  But to do this the primitive must be able to get at #identityHash or #basicNew.  Neither of these is close to hand.</div>
<div><br>
</div>
<div>I’ll have a root around and a think and see what I can come up with.</div>
<div><br>
<blockquote type="cite">
<div dir="ltr"><br>
Best,<br>
Christoph<br>
<br>
[1] Pointer if you want to read up to bloody details by yourself: <a href="https://github.com/LinqLover/SimulationStudio/pull/34/commits/0a55a8a23b6e842548049c07cbd96120a30cd06e">
https://github.com/LinqLover/SimulationStudio/pull/34/commits/0a55a8a23b6e842548049c07cbd96120a30cd06e</a><br>
<br>
<font color="#808080">---<br>
</font><font color="#808080"><i>Sent from </i></font><font color="#808080"><i><a href="https://github.com/hpi-swa-lab/squeak-inbox-talk"><u><font color="#808080">Squeak Inbox Talk</font></u></a></i></font><span></span><br>
</div>
</blockquote>
</div>
</div>
</body>
</html>