Hi Eliot,<br>
<br>
I just have implemented your idea in Kernel-ct.1451 (inbox). Hope you like it! :-)<br>
<br>
Do you have any further suggestions or may I move KernelTests-ct.420, Kernel-ct.1448, KernelTests-ct.421, Kernel-ct.1449, and Kernel-ct.1451 to the Trunk?<br>
<br>
Best,<br>
Christoph<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><br>
<br>
On 2022-03-14T00:37:07+00:00, christoph.thiede@student.hpi.uni-potsdam.de wrote:<br>
<br>
> Hi Eliot, thanks for the fast feedback.<br>
> <br>
> <br>
> > Wow that's a huge side-effect for such a basic operation. Not only that, the method lives in the method dictionary until the ensure: block us run and that could potentially be never. Isn't it preferable to determine if compiledMethod has a primitive, if so to use the doPrimitive:.../tryNamedPrimitiveIn:/tryPrimitive: machinery to execute the primitive, and then if the primitive fails create an activation of compiledMethod via Context class>>sender:receiver:method:arguments: and set that going via swapSender: tricks?<br>
> <br>
> Very nice idea! So basically Context>>#send:to:with:lookupIn: without the lookup part. I'm looking forward to implementing this, but it might take me some more days ... Busy times ... :-)<br>
> <br>
> Best,<br>
> Christoph<br>
> <br>
> ________________________________<br>
> Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Eliot Miranda <eliot.miranda at gmail.com><br>
> Gesendet: Samstag, 12. März 2022 02:41:49<br>
> An: The general-purpose Squeak developers list<br>
> Betreff: Re: [squeak-dev] The Inbox: Kernel-ct.1448.mcz<br>
> <br>
> Hi Christoph,<br>
> <br>
> your fixes look good. I was on the verge of moving them to trunk when I looked at the failure code in Object>>withArgs:executeMethod:<br>
> <br>
> Object>>withArgs: argArray executeMethod: compiledMethod<br>
> "Execute compiledMethod against the receiver and args in argArray"<br>
> <br>
> | selector |<br>
> <primitive: 188><br>
> selector := Symbol new.<br>
> self class addSelectorSilently: selector withMethod: compiledMethod.<br>
> ^ [self perform: selector withArguments: argArray]<br>
> ensure: [self class basicRemoveSelector: selector]<br>
> <br>
> Wow that's a huge side-effect for such a basic operation. Not only that, the method lives in the method dictionary until the ensure: block us run and that could potentially be never. Isn't it preferable to determine if compiledMethod has a primitive, if so to use the doPrimitive:.../tryNamedPrimitiveIn:/tryPrimitive: machinery to execute the primitive, and then if the primitive fails create an activation of compiledMethod via Context class>>sender:receiver:method:arguments: and set that going via swapSender: tricks?<br>
> <br>
> If you agree can I ask you to submit a Kernel with the implementation?<br>
> <br>
> On Fri, Mar 11, 2022 at 4:56 PM Thiede, Christoph <Christoph.Thiede at student.hpi.uni-potsdam.de<mailto:Christoph.Thiede at student.hpi.uni-potsdam.de>> wrote:<br>
> <br>
> Hi Eliot, hi all,<br>
> <br>
> <br>
> I have dropped a few versions in the inbox that improve the simulation of primitive 189, 183, 184 and also add tests for them. Please see: KernelTests-ct.420, Kernel-ct.1448, KernelTests-ct.421, and Kernel-ct.1449. Also, there are even more primitive tests in KernelTests-ct.409 (inbox), but they do not need to be reviewed together. I am looking forward to your feedback, please let me know when I can move these changes to the Trunk! :-)<br>
> <br>
> <br>
> Best,<br>
> <br>
> Christoph<br>
> <br>
> <br>
> ________________________________<br>
> Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org<mailto:squeak-dev-bounces at lists.squeakfoundation.org>> im Auftrag von commits at source.squeak.org<mailto:commits at source.squeak.org> <commits at source.squeak.org<mailto:commits at source.squeak.org>><br>
> Gesendet: Samstag, 12. März 2022 00:42:12<br>
> An: squeak-dev at lists.squeakfoundation.org<mailto:squeak-dev at lists.squeakfoundation.org><br>
> Betreff: [squeak-dev] The Inbox: Kernel-ct.1448.mcz<br>
> <br>
> A new version of Kernel was added to project The Inbox:<br>
> http://source.squeak.org/inbox/Kernel-ct.1448.mcz<br>
> <br>
> ==================== Summary ====================<br>
> <br>
> Name: Kernel-ct.1448<br>
> Author: ct<br>
> Time: 12 March 2022, 12:42:08.516359 am<br>
> UUID: 7659c202-5fcc-084e-84b4-a5d233717b2d<br>
> Ancestors: Kernel-nice.1447<br>
> <br>
> Implements missing simulation of primitive 189 primitiveExecuteMethod (Object>>with:...executeMethod:).<br>
> <br>
> =============== Diff against Kernel-nice.1447 ===============<br>
> <br>
> Item was changed:<br>
> ----- Method: Context>>doPrimitive:method:receiver:args: (in category 'private') -----<br>
> doPrimitive: primitiveIndex method: meth receiver: receiver args: arguments<br>
> "Simulate a primitive method whose index is primitiveIndex. The simulated receiver and<br>
> arguments are given as arguments to this message. If successful, push result and return<br>
> resuming context, else ^ {errCode, PrimitiveFailToken}. Any primitive which provokes<br>
> execution needs to be intercepted and simulated to avoid execution running away."<br>
> <br>
> | value |<br>
> "Judicious use of primitive 19 (a null primitive that doesn't do anything) prevents<br>
> the debugger from entering various run-away activities such as spawning a new<br>
> process, etc. Injudicious use results in the debugger not being able to debug<br>
> interesting code, such as the debugger itself. Hence use primitive 19 with care :-)"<br>
> "SystemNavigation new browseAllSelect: [:m| m primitive = 19]"<br>
> primitiveIndex = 19 ifTrue: [<br>
> [self notify: ('The code being simulated is trying to control a process ({1}). Process controlling cannot be simulated. If you proceed, things may happen outside the observable area of the simulator.' translated format: {meth reference})]<br>
> ifCurtailed: [self push: nil "Cheap fix of the context's internal state"]].<br>
> <br>
> ((primitiveIndex between: 201 and: 222)<br>
> and: [(self objectClass: receiver) includesBehavior: BlockClosure]) ifTrue:<br>
> [(primitiveIndex = 206<br>
> or: [primitiveIndex = 208]) ifTrue: "[Full]BlockClosure>>valueWithArguments:"<br>
> [^receiver simulateValueWithArguments: arguments first caller: self].<br>
> ((primitiveIndex between: 201 and: 209) "[Full]BlockClosure>>value[:value:...]"<br>
> or: [primitiveIndex between: 221 and: 222]) ifTrue: "[Full]BlockClosure>>valueNoContextSwitch[:]"<br>
> [^receiver simulateValueWithArguments: arguments caller: self]].<br>
> <br>
> primitiveIndex = 83 ifTrue: "afr 9/11/1998 19:50" "Object>>perform:[with:...]"<br>
> [| selector |<br>
> selector := arguments at: 1 ifAbsent:<br>
> [^ self class primitiveFailTokenFor: #'bad argument'].<br>
> arguments size - 1 = selector numArgs ifFalse:<br>
> [^ self class primitiveFailTokenFor: #'bad number of arguments'].<br>
> ^self send: selector to: receiver with: arguments allButFirst].<br>
> primitiveIndex = 84 ifTrue: "afr 9/11/1998 19:50 & eem 8/18/2009 17:04" "Object>>perform:withArguments:"<br>
> [| selector args |<br>
> arguments size = 2 ifFalse:<br>
> [^ self class primitiveFailTokenFor: #'bad argument'].<br>
> selector := arguments first.<br>
> args := arguments second.<br>
> args isArray ifFalse:<br>
> [^ self class primitiveFailTokenFor: #'bad argument'].<br>
> args size = selector numArgs ifFalse:<br>
> [^ self class primitiveFailTokenFor: #'bad number of arguments'].<br>
> ^self send: selector to: receiver with: args].<br>
> primitiveIndex = 100 ifTrue: "eem 8/18/2009 16:57" "Object>>perform:withArguments:inSuperclass:"<br>
> [| rcvr selector args superclass |<br>
> arguments size<br>
> caseOf: {<br>
> [3] -> [<br>
> rcvr := receiver.<br>
> selector := arguments first.<br>
> args := arguments second.<br>
> superclass := arguments third].<br>
> [4] -> ["mirror primitive"<br>
> rcvr := arguments first.<br>
> selector := arguments second.<br>
> args := arguments third.<br>
> superclass := arguments fourth] }<br>
> otherwise: [^ self class primitiveFailTokenFor: #'bad argument'].<br>
> args isArray ifFalse:<br>
> [^ self class primitiveFailTokenFor: #'bad argument'].<br>
> args size = selector numArgs ifFalse:<br>
> [^ self class primitiveFailTokenFor: #'bad number of arguments'].<br>
> ((self objectClass: rcvr) includesBehavior: superclass) ifFalse:<br>
> [^ self class primitiveFailTokenFor: #'bad argument'].<br>
> ^self send: selector to: rcvr with: args lookupIn: superclass].<br>
> <br>
> "Mutex>>primitiveEnterCriticalSection<br>
> Mutex>>primitiveTestAndSetOwnershipOfCriticalSection"<br>
> (primitiveIndex = 186 or: [primitiveIndex = 187]) ifTrue:<br>
> [| effective |<br>
> effective := Processor activeProcess effectiveProcess.<br>
> "active == effective"<br>
> value := primitiveIndex = 186<br>
> ifTrue: [receiver primitiveEnterCriticalSectionOnBehalfOf: effective]<br>
> ifFalse: [receiver primitiveTestAndSetOwnershipOfCriticalSectionOnBehalfOf: effective].<br>
> ^(self isPrimFailToken: value)<br>
> ifTrue: [value]<br>
> ifFalse: [self push: value]].<br>
> +<br>
> + (primitiveIndex = 188 or: [primitiveIndex = 189]) ifTrue:<br>
> -<br>
> - primitiveIndex = 188 ifTrue: "Object>>withArgs:executeMethod:<br>
> - CompiledMethod class>>receiver:withArguments:executeMethod:<br>
> - VMMirror>>ifFail:object:with:executeMethod: et al"<br>
> [| n args methodArg thisReceiver |<br>
> + primitiveIndex caseOf:<br>
> + {[188 "primitiveExecuteMethodArgsArray"] -><br>
> + ["Object>>withArgs:executeMethod:<br>
> + CompiledMethod class>>receiver:withArguments:executeMethod:<br>
> + VMMirror>>ifFail:object:with:executeMethod: et al"<br>
> + ((n := arguments size) between: 2 and: 4) ifFalse:<br>
> + [^self class primitiveFailTokenFor: #'unsupported operation'].<br>
> + ((self objectClass: (args := arguments at: n - 1)) == Array<br>
> + and: [(self objectClass: (methodArg := arguments at: n)) includesBehavior: CompiledMethod]) ifFalse:<br>
> + [^self class primitiveFailTokenFor: #'bad argument'].<br>
> + thisReceiver := arguments at: n - 2 ifAbsent: [receiver]].<br>
> + [189 "primitiveExecuteMethod"] -><br>
> + ["Object>>executeMethod:<br>
> + Object>>with:...executeMethod:"<br>
> + (arguments size > 0) ifFalse:<br>
> + [^self class primitiveFailTokenFor: #'bad argument'].<br>
> + ((self objectClass: (methodArg := arguments atLast: 1)) includesBehavior: CompiledMethod) ifFalse:<br>
> + [^self class primitiveFailTokenFor: #'bad argument'].<br>
> + args := arguments allButLast.<br>
> + thisReceiver := receiver]}.<br>
> - ((n := arguments size) between: 2 and: 4) ifFalse:<br>
> - [^self class primitiveFailTokenFor: #'unsupported operation'].<br>
> - ((self objectClass: (args := arguments at: n - 1)) == Array<br>
> - and: [(self objectClass: (methodArg := arguments at: n)) includesBehavior: CompiledMethod]) ifFalse:<br>
> - [^self class primitiveFailTokenFor: #'bad argument'].<br>
> methodArg numArgs = args size ifFalse:<br>
> [^self class primitiveFailTokenFor: #'bad number of arguments'].<br>
> - thisReceiver := arguments at: n - 2 ifAbsent: [receiver].<br>
> methodArg primitive > 0 ifTrue:<br>
> [methodArg isQuick ifTrue:<br>
> [^self push: (methodArg valueWithReceiver: thisReceiver arguments: args)].<br>
> ^self doPrimitive: methodArg primitive method: meth receiver: thisReceiver args: args].<br>
> ^self<br>
> activateMethod: methodArg<br>
> withArgs: args<br>
> receiver: thisReceiver].<br>
> <br>
> primitiveIndex = 118 ifTrue: "[receiver:]tryPrimitive:withArgs:; avoid recursing in the VM"<br>
> [(arguments size = 3<br>
> and: [(self objectClass: arguments second) == SmallInteger<br>
> and: [(self objectClass: arguments last) == Array]]) ifTrue:<br>
> [^self doPrimitive: arguments second method: meth receiver: arguments first args: arguments last].<br>
> (arguments size = 2<br>
> and: [(self objectClass: arguments first) == SmallInteger<br>
> and: [(self objectClass: arguments last) == Array]]) ifFalse:<br>
> [^self class primitiveFailTokenFor: nil].<br>
> ^self doPrimitive: arguments first method: meth receiver: receiver args: arguments last].<br>
> <br>
> value := primitiveIndex = 120 "FFI method"<br>
> ifTrue: [(meth literalAt: 1) tryInvokeWithArguments: arguments]<br>
> ifFalse:<br>
> [primitiveIndex = 117 "named primitives"<br>
> ifTrue: [self tryNamedPrimitiveIn: meth for: receiver withArgs: arguments]<br>
> ifFalse: "should use self receiver: receiver tryPrimitive: primitiveIndex withArgs: arguments but this is only in later VMs (and appears to be broken)"<br>
> [receiver tryPrimitive: primitiveIndex withArgs: arguments]].<br>
> <br>
> ^(self isPrimFailToken: value)<br>
> ifTrue: [value]<br>
> ifFalse: [self push: value]!<br>
> <br>
> <br>
> <br>
> <br>
> <br>
> --<br>
> _,,,^..^,,,_<br>
> best, Eliot<br>
> -------------- next part --------------<br>
> An HTML attachment was scrubbed...<br>
> URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220314/91ddf63a/attachment.html><br>
> <br>
>