<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
+1<div><br></div><div>Also see Magnitude >> #between:and: :-)</div><div><br></div><div>Best,</div><div>Marcel</div><div class="mb_sig"></div>
<blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
<p style="color: #AAAAAA; margin-top: 10px;">Am 15.03.2021 13:52:19 schrieb commits@source.squeak.org <commits@source.squeak.org>:</p><div style="font-family:Arial,Helvetica,sans-serif">A new version of Kernel was added to project The Inbox:<br>http://source.squeak.org/inbox/Kernel-ct.1382.mcz<br><br>==================== Summary ====================<br><br>Name: Kernel-ct.1382<br>Author: ct<br>Time: 15 March 2021, 1:52:03.249869 pm<br>UUID: e108423f-661f-4d4f-9ad8-c667c3995b32<br>Ancestors: Kernel-mt.1381<br><br>Proposal: Revises usage and handling of primitive 19, also known as the simulation guard. Don't use it in #newProcess and variants since they don't involve any actual control logic. Instead, also show a simulation warning when debugging a control primitive (primitiveSignal primitiveWait primitiveResume primitiveSuspend). Improves integration of simulation guard warnings by signaling a Warning on the simulator stack rather than spawning a debugger on the debugged process. This also makes it easier to handle these warnings in a non-interactive context. See http://forum.world.st/Simulation-guard-lt-primitive-19-gt-crashes-the-image-td5127443.html and http://forum.world.st/Please-try-out-Fixes-for-debugger-invocation-during-code-simulation-td5127684.html for more information.<br><br>Reuploaded to resolve merge conflict with Kernel-mt.1381. Replaces Kernel-ct.1381, which can be moved into the treated inbox.<br><br>=============== Diff against Kernel-mt.1381 ===============<br><br>Item was changed:<br> ----- Method: BlockClosure>>newProcess (in category 'scheduling') -----<br> newProcess<br>+ "Answer a Process running the code in the receiver. The process is not scheduled."<br>- "Answer a Process running the code in the receiver. The process is not <br>- scheduled."<br>- <primitive: 19=""> "Simulation guard"<br> ^Process<br> forContext: <br> [self value.<br>+ "Since control is now at the bottom, there is no need to terminate (which runs unwinds) since all unwinds have been run. Simply suspend.<br>+ Note that we must use this form rather than e.g. Processor suspendActive so that isTerminated answers true. isTerminated requires that if there is a suspended context it is the bottom-most, but using a send would result in the process's suspendedContext /not/ being the bottom-most."<br>- "Since control is now at the bottom there is no need to terminate (which<br>- runs unwinds) since all unwnds have been run. Simply suspend.<br>- Note that we must use this form rather than e.g. Processor suspendActive<br>- so that isTerminated answers true. isTerminated requires that if there is a<br>- suspended context it is the bottom-most, but using a send would result in<br>- the process's suspendedContext /not/ being the bottom-most."<br> Processor activeProcess suspend] asContext<br> priority: Processor activePriority!<br><br>Item was changed:<br> ----- Method: BlockClosure>>newProcessWith: (in category 'scheduling') -----<br> newProcessWith: anArray <br>+ "Answer a Process running the code in the receiver. The receiver's block arguments are bound to the contents of the argument, anArray. The process is not scheduled."<br>- "Answer a Process running the code in the receiver. The receiver's block <br>- arguments are bound to the contents of the argument, anArray. The <br>- process is not scheduled."<br>- <primitive: 19=""> "Simulation guard"<br> ^Process<br> forContext: <br> [self valueWithArguments: anArray.<br>+ "Since control is now at the bottom, there is no need to terminate (which runs unwinds) since all unwinds have been run. Simply suspend.<br>+ Note that we must use this form rather than e.g. Processor suspendActive so that isTerminated answers true. isTerminated requires that if there is a suspended context it is the bottom-most, but using a send would result in the process's suspendedContext /not/ being the bottom-most."<br>- "Since control is now at the bottom there is no need to terminate (which<br>- runs unwinds) since all unwnds have been run. Simply suspend.<br>- Note that we must use this form rather than e.g. Processor suspendActive<br>- so that isTerminated answers true. isTerminated requires that if there is a<br>- suspended context it is the bottom-most, but using a send would result in<br>- the process's suspendedContext /not/ being the bottom-most."<br> Processor activeProcess suspend] asContext<br> priority: Processor activePriority!<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 or: [primitiveIndex >= 85 and: [primitiveIndex <= 88] "control primitives"]) ifTrue: [<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> [^self send: arguments first 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> [^self send: arguments first to: receiver with: (arguments at: 2) lookupIn: (self objectClass: receiver)].<br> primitiveIndex = 100 ifTrue: "eem 8/18/2009 16:57" "Object>>perform:withArguments:inSuperclass:"<br> [^self send: arguments first to: receiver with: (arguments at: 2) lookupIn: (arguments at: 3)].<br> <br> "Mutex>>primitiveEnterCriticalSection<br> Mutex>>primitiveTestAndSetOwnershipOfCriticalSection"<br> (primitiveIndex = 186 or: [primitiveIndex = 187]) ifTrue:<br>+ ["Transcript<br>+ cr;<br>+ nextPutAll: 'Processor activeProcess ';<br>+ nextPutAll: (Processor activeProcess == receiver owningProcess ifTrue: [#==] ifFalse: [#~~]);<br>+ nextPutAll: ' owner';<br>+ flush."<br>+ value := primitiveIndex = 186<br>+ ifTrue: [receiver primitiveEnterCriticalSectionOnBehalfOf: Processor activeProcess]<br>+ ifFalse: [receiver primitiveTestAndSetOwnershipOfCriticalSectionOnBehalfOf: Processor activeProcess].<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 ifTrue: "Object>>withArgs:executeMethod:<br> CompiledMethod class>>receiver:withArguments:executeMethod:<br> VMMirror>>ifFail:object:with:executeMethod: et al"<br> [| n args methodArg thisReceiver |<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> ^Context<br> sender: self<br> receiver: thisReceiver<br> method: methodArg<br> arguments: args].<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></primitive:></primitive:></div></blockquote></div>