<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr">Hi Jaromir,</div><div dir="ltr"><br><blockquote type="cite">On Sep 19, 2022, at 7:13 AM, Jaromir Matas <mail@jaromir.net> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr">

<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style>@font-face { font-family: "Cambria Math"; }
@font-face { font-family: Calibri; }
p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif; }
a:link, span.MsoHyperlink { color: blue; text-decoration: underline; }
.MsoChpDefault { }
@page WordSection1 { size: 8.5in 11in; margin: 1in; }
div.WordSection1 { page: WordSection1; }</style>


<div class="WordSection1">
<p class="MsoNormal"><span lang="CS">Hi Eliot, Christoph,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">I have a question re: [Vm-dev] [OpenSmalltalk/opensmalltalk-vm] pushRcvr fails for context instances whose sender has been set to an Integer instance (Issue #654):<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">Why would one want to be able to send `privSender: 1` ? Is it useful for something? Otherwise I'm thinking why not block such an assignment inside #privSender e.g. like this:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">Context>>privSender: aContextOrNil<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="CS">        sender := aContextOrNil ifNotNil: [aContextOrNil asContext]</span></p></div></div></blockquote><div><br></div>Well, I find the convention weak, but the implication of the priv prefix in privSender: et al is that these are private selectors, and hence only used within Context (clearly violated in a few places) and hence only correctly.<div><br></div><div>However, your idea is a good one; I’ll add it.</div><div><span style="font-size: 11pt; font-family: Calibri, sans-serif;"><br></span></div><div><span style="font-size: 11pt; font-family: Calibri, sans-serif;"> </span></div><div><blockquote type="cite"><div dir="ltr"><div class="WordSection1">
<p class="MsoNormal"><span lang="CS">As a side-effect this would allow e.g. blocks to be used as reasonable arguments too...</span></p></div></div></blockquote><div><br></div>Which might simplify some debugger code.</div><div><br></div><div>But should the selector be simply sender: or setSender: ?  And what about swapSender: ?  I like sending isContext in several places to validate the argument.  I also find the sends to access sender in e.g. insertSender: unnecessary and complicating.</div><div><br></div><div>I like the idea of cleaning up this code. There’s lots of old code and some duplication.  Let’s keep polishing.</div><div><br><blockquote type="cite"><div dir="ltr"><div class="WordSection1"><p class="MsoNormal"><span lang="CS"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="CS"><o:p> </o:p></span><span style="font-size: 11pt;">Thanks,</span></p>
<p class="MsoNormal"><span lang="CS">Jaromir</span></p></div></div></blockquote><div><br></div>Eliot<br><div dir="ltr"><span style="background-color: rgba(255, 255, 255, 0);">_,,,^..^,,,_ (phone)</span></div><div id="AppleMailSignature" dir="ltr"><br></div><blockquote type="cite"><div dir="ltr"><div class="WordSection1">

<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a><br>
<b>Sent: </b>Monday, September 19, 2022 1:29<br>
<b>To: </b><a href="mailto:squeak-dev@lists.squeakfoundation.org">squeak-dev@lists.squeakfoundation.org</a><br>
<b>Subject: </b>[squeak-dev] The Inbox: Kernel-eem.1489.mcz</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">A new version of Kernel was added to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Kernel-eem.1489.mcz">http://source.squeak.org/inbox/Kernel-eem.1489.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Kernel-eem.1489<br>
Author: eem<br>
Time: 18 September 2022, 4:29:27.672168 pm<br>
UUID: 825872cd-7b3f-48cb-b765-0fa7bb4b4f21<br>
Ancestors: Kernel-eem.1488<br>
<br>
Ensure that a Context can only be instantiated via newForMethod:, and that the resulting Context has its method inst var initiialized.<br>
<br>
=============== Diff against Kernel-eem.1488 ===============<br>
<br>
Item was changed:<br>
  ----- Method: BlockClosure>>asContextWithSender: (in category 'private') -----<br>
  asContextWithSender: aContext<br>
         "Inner private support method for evaluation.  Do not use unless you know what you're doing."<br>
  <br>
         ^(Context newForMethod: outerContext method)<br>
                 setSender: aContext<br>
                 receiver: outerContext receiver<br>
-                method: outerContext method<br>
                 closure: self<br>
                 startpc: startpcOrMethod;<br>
                 privRefresh!<br>
<br>
Item was changed:<br>
  ----- Method: BlockClosure>>simulateValueWithArguments:caller: (in category 'system simulation') -----<br>
  simulateValueWithArguments: anArray caller: aContext<br>
         "Simulate the valueWithArguments: primitive. Fail if anArray is not an array of the right arity."<br>
         | newContext sz |<br>
         newContext := (Context newForMethod: outerContext method)<br>
                                                 setSender: aContext<br>
                                                 receiver: outerContext receiver<br>
-                                                method: outerContext method<br>
                                                 closure: self<br>
                                                 startpc: startpcOrMethod.<br>
         ((newContext objectClass: anArray) ~~ Array<br>
          or: [numArgs ~= anArray size]) ifTrue:<br>
                 [^Context primitiveFailTokenFor: nil].<br>
         sz := self basicSize.<br>
         newContext stackp: sz + numArgs.<br>
         1 to: numArgs do:<br>
                 [:i| newContext at: i put: (anArray at: i)].<br>
         1 to: sz do:<br>
                 [:i| newContext at: i + numArgs put: (self at: i)].<br>
         ^newContext!<br>
<br>
Item was changed:<br>
  ----- Method: Context class>>basicNew: (in category 'instance creation') -----<br>
  basicNew: size <br>
+        self instanceCreationError!<br>
-        ^ (size = CompiledMethod smallFrameSize or: [ size = CompiledMethod fullFrameSize ])<br>
-                ifTrue: [ super basicNew: size ]<br>
-                ifFalse: [ self error: 'Contexts must be ' , CompiledMethod smallFrameSize , ' or ' , CompiledMethod fullFrameSize , ' bytes.' ]!<br>
<br>
Item was added:<br>
+ ----- Method: Context class>>instanceCreationError (in category 'private') -----<br>
+ instanceCreationError<br>
+        self error: 'Contexts must only be created with newForMethod:'!<br>
<br>
Item was changed:<br>
  ----- Method: Context class>>new (in category 'instance creation') -----<br>
  new<br>
+        self instanceCreationError!<br>
- <br>
-        self error: 'Contexts must only be created with newForMethod:'!<br>
<br>
Item was changed:<br>
  ----- Method: Context class>>new: (in category 'instance creation') -----<br>
  new: size<br>
+        self instanceCreationError!<br>
- <br>
-        self error: 'Contexts must only be created with newForMethod:'!<br>
<br>
Item was changed:<br>
  ----- Method: Context class>>newForMethod: (in category 'instance creation') -----<br>
+ newForMethod: aCompiledCode<br>
- newForMethod: aMethod<br>
         "This is the only method for creating new contexts, other than primitive cloning.<br>
         Any other attempts, such as inherited methods like shallowCopy, should be<br>
         avoided or must at least be rewritten to determine the proper size from the<br>
         method being activated.  This is because asking a context its size (even basicSize!!)<br>
         will not return the real object size but only the number of fields currently<br>
         accessible, as determined by stackp."<br>
  <br>
+        ^(super basicNew: aCompiledCode frameSize)<br>
+                privMethod: aCompiledCode!<br>
-        ^ super basicNew: aMethod frameSize!<br>
<br>
Item was changed:<br>
  ----- Method: Context class>>sender:receiver:method:arguments: (in category 'instance creation') -----<br>
  sender: s receiver: r method: m arguments: args <br>
         "Answer an instance of me with attributes set to the arguments."<br>
  <br>
+        ^(self newForMethod: m) setSender: s receiver: r arguments: args!<br>
-        ^(self newForMethod: m) setSender: s receiver: r method: m arguments: args!<br>
<br>
Item was added:<br>
+ ----- Method: Context>>privMethod: (in category 'private') -----<br>
+ privMethod: aCompiledCode<br>
+ <br>
+        method := aCompiledCode!<br>
<br>
Item was added:<br>
+ ----- Method: Context>>setSender:receiver:arguments: (in category 'private') -----<br>
+ setSender: s receiver: r arguments: args <br>
+        "Initialize the receiver's initial state."<br>
+ <br>
+        pc := method initialPC.<br>
+        self stackp: method numTemps.<br>
+        sender := s.<br>
+        receiver := r.<br>
+        closureOrNil := nil.<br>
+        1 to: args size do: [:i | self at: i put: (args at: i)]!<br>
<br>
Item was added:<br>
+ ----- Method: Context>>setSender:receiver:closure:startpc: (in category 'private') -----<br>
+ setSender: s receiver: r closure: c startpc: startpc<br>
+        "Create the receiver's initial state."<br>
+ <br>
+        sender := s.<br>
+        receiver := r.<br>
+        closureOrNil := c.<br>
+        pc := startpc.<br>
+        stackp := 0!<br>
<br>
Item was removed:<br>
- ----- Method: Context>>setSender:receiver:method:arguments: (in category 'private') -----<br>
- setSender: s receiver: r method: m arguments: args <br>
-        "Create the receiver's initial state."<br>
- <br>
-        sender := s.<br>
-        receiver := r.<br>
-        method := m.<br>
-        closureOrNil := nil.<br>
-        pc := method initialPC.<br>
-        self stackp: method numTemps.<br>
-        1 to: args size do: [:i | self at: i put: (args at: i)]!<br>
<br>
Item was removed:<br>
- ----- Method: Context>>setSender:receiver:method:closure:startpc: (in category 'private') -----<br>
- setSender: s receiver: r method: m closure: c startpc: startpc<br>
-        "Create the receiver's initial state."<br>
- <br>
-        sender := s.<br>
-        receiver := r.<br>
-        method := m.<br>
-        closureOrNil := c.<br>
-        pc := startpc.<br>
-        stackp := 0!<br>
<br>
Item was changed:<br>
  ----- Method: FullBlockClosure>>asContextWithSender: (in category 'private') -----<br>
  asContextWithSender: aContext<br>
         "Inner private support method for evaluation.  Do not use unless you know what you're doing."<br>
  <br>
         ^(Context newForMethod: startpcOrMethod)<br>
                 setSender: aContext<br>
                 receiver: self receiver<br>
-                method: startpcOrMethod<br>
                 closure: self<br>
                 startpc: startpcOrMethod initialPC;<br>
                 privRefresh!<br>
<br>
Item was changed:<br>
  ----- Method: FullBlockClosure>>simulateValueWithArguments:caller: (in category 'simulation') -----<br>
  simulateValueWithArguments: anArray caller: aContext<br>
         "Simulate the valueWithArguments: primitive. Fail if anArray is not an array of the right arity."<br>
         | newContext |<br>
         newContext := (Context newForMethod: startpcOrMethod)<br>
                                                 setSender: aContext<br>
                                                 receiver: receiver<br>
-                                                method: startpcOrMethod<br>
                                                 closure: self<br>
                                                 startpc: startpcOrMethod initialPC.<br>
         ((newContext objectClass: anArray) ~~ Array<br>
          or: [numArgs ~= anArray size]) ifTrue:<br>
                 [^Context primitiveFailTokenFor: nil].<br>
         newContext stackp: startpcOrMethod numTemps.<br>
         1 to: numArgs do:<br>
                 [:i| newContext at: i put: (anArray at: i)].<br>
         1 to: self basicSize do:<br>
                 [:i| newContext at: i + numArgs put: (self at: i)].<br>
         ^newContext!<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>


<span></span><br></div></blockquote></div></body></html>