Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.932.mcz
==================== Summary ====================
Name: Collections-ul.932
Author: ul
Time: 31 March 2021, 2:12:26.200489 am
UUID: a61726a6-a12e-4074-a25f-8220699d3c06
Ancestors: Collections-dtl.931
- use #grownBy: in WriteStream >> #growTo: to grow the collection because that works for OrderedCollections too.
- do not add 10 to the argument passed to WriteStream >> #growTo:. It will already increase its argument by at least 20.
=============== Diff against Collections-dtl.931 ===============
Item was changed:
----- Method: LimitedWriteStream>>nextPutAll: (in category 'writing') -----
nextPutAll: aCollection
| newEnd |
collection class == aCollection class ifFalse:
[^ super nextPutAll: aCollection ].
newEnd := position + aCollection size.
newEnd > limit ifTrue: [
super nextPutAll: (aCollection copyFrom: 1 to: (limit - position max: 0)).
limitBlock value.
^aCollection
].
newEnd > writeLimit ifTrue: [
+ self growTo: newEnd
- self growTo: newEnd + 10
].
collection replaceFrom: position+1 to: newEnd with: aCollection startingAt: 1.
position := newEnd.
^aCollection!
Item was changed:
----- Method: TextStream>>nextPutAll: (in category 'writing') -----
nextPutAll: aCollection
"Optimized access to get around Text at:Put: overhead"
| n |
n := aCollection size.
position + n > writeLimit
ifTrue:
+ [self growTo: position + n].
- [self growTo: position + n + 10].
collection
replaceFrom: position+1
to: position + n
with: aCollection
startingAt: 1.
position := position + n.
^aCollection!
Item was changed:
----- Method: WriteStream>><< (in category 'printing') -----
<< aCollection
"we want a readable version of nextPutAll however it may be difficult to fully recreate nextPutAll:
for all the different types of stream. Rather then simply send to nextPutAll:
we handle the String (or ByteArray) argument
as fast as possible - the rest we delegate to putOn: This means that we handle single characters and bytes
whereas nextPutAll: is only for sequencable collections.
.
Note this may not work in every case that nextPutAll: does subject to extensive testing,
but it should work in the important cases"
| newEnd |
collection class == aCollection class ifFalse:
[ aCollection putOn: self. ^ self ].
newEnd := position + aCollection size.
newEnd > writeLimit ifTrue:
+ [self growTo: newEnd].
- [self growTo: newEnd + 10].
collection replaceFrom: position+1 to: newEnd with: aCollection startingAt: 1.
position := newEnd.
!
Item was changed:
----- Method: WriteStream>>growTo: (in category 'private') -----
growTo: anInteger
+ " anInteger is the required minimal new size of the collection "
+ | oldSize newSize |
- " anInteger is the required minimal new size of the collection "
- | oldSize grownCollection newSize |
oldSize := collection size.
+ newSize := anInteger + (oldSize // 4 max: 20).
+ collection := collection grownBy: newSize - oldSize.
- newSize := anInteger + (oldSize // 4 max: 20).
- grownCollection := collection class new: newSize.
- collection := grownCollection replaceFrom: 1 to: oldSize with: collection startingAt: 1.
writeLimit := collection size.
!
Item was changed:
----- Method: WriteStream>>next:putAll:startingAt: (in category 'accessing') -----
next: anInteger putAll: aCollection startingAt: startIndex
"Store the next anInteger elements from the given collection."
| newEnd |
anInteger > 0 ifFalse: [ ^aCollection ].
(collection class == aCollection class
or: [ collection isString
and: [ aCollection isString
and: [ collection class format = aCollection class format ] ] ]) "Let Strings with the same field size as collection take the quick route too."
ifFalse: [ ^super next: anInteger putAll: aCollection startingAt: startIndex ].
newEnd := position + anInteger.
newEnd > writeLimit ifTrue:
+ [self growTo: newEnd].
- [self growTo: newEnd + 10].
collection replaceFrom: position+1 to: newEnd with: aCollection startingAt: startIndex.
position := newEnd.
^aCollection!
Item was changed:
----- Method: WriteStream>>nextPutAll: (in category 'accessing') -----
nextPutAll: aCollection
| newEnd |
(collection class == aCollection class
or: [ collection class isBits
and: [ aCollection isString
and: [ collection class format = aCollection class format ] ] ]) "Let Strings with the same field size as collection take the quick route too."
ifFalse: [ ^ super nextPutAll: aCollection ].
newEnd := position + aCollection size.
newEnd > writeLimit ifTrue:
+ [self growTo: newEnd].
- [self growTo: newEnd + 10].
collection replaceFrom: position+1 to: newEnd with: aCollection startingAt: 1.
position := newEnd.
^aCollection!
Tony Garnock-Jones uploaded a new version of Environments to project The Trunk:
http://source.squeak.org/trunk/Environments-tonyg.81.mcz
==================== Summary ====================
Name: Environments-tonyg.81
Author: tonyg
Time: 29 March 2021, 10:20:10.069623 am
UUID: 3b64bc37-b2d0-4b78-85fe-fa13775df713
Ancestors: Environments-tonyg.80
Repair EnvironmentRequest signal.
=============== Diff against Environments-tonyg.80 ===============
Item was changed:
----- Method: EnvironmentRequest>>defaultAction (in category 'exceptionDescription') -----
defaultAction
| all environment |
all := Environment allInstances.
+ environment := UIManager default
+ chooseFrom: (all collect: [:ea | ea printString])
+ values: all.
- environment := UIManager default chooseFrom: all values: all.
self resume: environment.!
Marcel Taeumel uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ct.1382.mcz
==================== Summary ====================
Name: Kernel-ct.1382
Author: ct
Time: 15 March 2021, 1:52:03.249869 pm
UUID: e108423f-661f-4d4f-9ad8-c667c3995b32
Ancestors: Kernel-mt.1381
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… and http://forum.world.st/Please-try-out-Fixes-for-debugger-invocation-during-c… for more information.
Reuploaded to resolve merge conflict with Kernel-mt.1381. Replaces Kernel-ct.1381, which can be moved into the treated inbox.
=============== Diff against Kernel-mt.1381 ===============
Item was changed:
----- Method: BlockClosure>>newProcess (in category 'scheduling') -----
newProcess
+ "Answer a Process running the code in the receiver. The process is not scheduled."
- "Answer a Process running the code in the receiver. The process is not
- scheduled."
- <primitive: 19> "Simulation guard"
^Process
forContext:
[self value.
+ "Since control is now at the bottom, there is no need to terminate (which runs unwinds) since all unwinds have been run. Simply suspend.
+ 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."
- "Since control is now at the bottom there is no need to terminate (which
- runs unwinds) since all unwnds have been run. Simply suspend.
- 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."
Processor activeProcess suspend] asContext
priority: Processor activePriority!
Item was changed:
----- Method: BlockClosure>>newProcessWith: (in category 'scheduling') -----
newProcessWith: anArray
+ "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."
- "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."
- <primitive: 19> "Simulation guard"
^Process
forContext:
[self valueWithArguments: anArray.
+ "Since control is now at the bottom, there is no need to terminate (which runs unwinds) since all unwinds have been run. Simply suspend.
+ 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."
- "Since control is now at the bottom there is no need to terminate (which
- runs unwinds) since all unwnds have been run. Simply suspend.
- 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."
Processor activeProcess suspend] asContext
priority: Processor activePriority!
Item was changed:
----- Method: Context>>doPrimitive:method:receiver:args: (in category 'private') -----
doPrimitive: primitiveIndex method: meth receiver: receiver args: arguments
"Simulate a primitive method whose index is primitiveIndex. The simulated receiver and
arguments are given as arguments to this message. If successful, push result and return
resuming context, else ^ {errCode, PrimitiveFailToken}. Any primitive which provokes
execution needs to be intercepted and simulated to avoid execution running away."
| value |
"Judicious use of primitive 19 (a null primitive that doesn't do anything) prevents
the debugger from entering various run-away activities such as spawning a new
process, etc. Injudicious use results in the debugger not being able to debug
interesting code, such as the debugger itself. Hence use primitive 19 with care :-)"
"SystemNavigation new browseAllSelect: [:m| m primitive = 19]"
+ (primitiveIndex = 19 or: [primitiveIndex >= 85 and: [primitiveIndex <= 88] "control primitives"]) ifTrue: [
- primitiveIndex = 19 ifTrue: [
[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})]
ifCurtailed: [self push: nil "Cheap fix of the context's internal state"]].
((primitiveIndex between: 201 and: 222)
and: [(self objectClass: receiver) includesBehavior: BlockClosure]) ifTrue:
[(primitiveIndex = 206
or: [primitiveIndex = 208]) ifTrue: "[Full]BlockClosure>>valueWithArguments:"
[^receiver simulateValueWithArguments: arguments first caller: self].
((primitiveIndex between: 201 and: 209) "[Full]BlockClosure>>value[:value:...]"
or: [primitiveIndex between: 221 and: 222]) ifTrue: "[Full]BlockClosure>>valueNoContextSwitch[:]"
[^receiver simulateValueWithArguments: arguments caller: self]].
primitiveIndex = 83 ifTrue: "afr 9/11/1998 19:50" "Object>>perform:[with:...]"
[^self send: arguments first to: receiver with: arguments allButFirst].
primitiveIndex = 84 ifTrue: "afr 9/11/1998 19:50 & eem 8/18/2009 17:04" "Object>>perform:withArguments:"
[^self send: arguments first to: receiver with: (arguments at: 2) lookupIn: (self objectClass: receiver)].
primitiveIndex = 100 ifTrue: "eem 8/18/2009 16:57" "Object>>perform:withArguments:inSuperclass:"
[^self send: arguments first to: receiver with: (arguments at: 2) lookupIn: (arguments at: 3)].
"Mutex>>primitiveEnterCriticalSection
Mutex>>primitiveTestAndSetOwnershipOfCriticalSection"
(primitiveIndex = 186 or: [primitiveIndex = 187]) ifTrue:
+ ["Transcript
+ cr;
+ nextPutAll: 'Processor activeProcess ';
+ nextPutAll: (Processor activeProcess == receiver owningProcess ifTrue: [#==] ifFalse: [#~~]);
+ nextPutAll: ' owner';
+ flush."
+ value := primitiveIndex = 186
+ ifTrue: [receiver primitiveEnterCriticalSectionOnBehalfOf: Processor activeProcess]
+ ifFalse: [receiver primitiveTestAndSetOwnershipOfCriticalSectionOnBehalfOf: Processor activeProcess].
- [| effective |
- effective := Processor activeProcess effectiveProcess.
- "active == effective"
- value := primitiveIndex = 186
- ifTrue: [receiver primitiveEnterCriticalSectionOnBehalfOf: effective]
- ifFalse: [receiver primitiveTestAndSetOwnershipOfCriticalSectionOnBehalfOf: effective].
^(self isPrimFailToken: value)
ifTrue: [value]
ifFalse: [self push: value]].
primitiveIndex = 188 ifTrue: "Object>>withArgs:executeMethod:
CompiledMethod class>>receiver:withArguments:executeMethod:
VMMirror>>ifFail:object:with:executeMethod: et al"
[| n args methodArg thisReceiver |
((n := arguments size) between: 2 and: 4) ifFalse:
[^self class primitiveFailTokenFor: #'unsupported operation'].
((self objectClass: (args := arguments at: n - 1)) == Array
and: [(self objectClass: (methodArg := arguments at: n)) includesBehavior: CompiledMethod]) ifFalse:
[^self class primitiveFailTokenFor: #'bad argument'].
methodArg numArgs = args size ifFalse:
[^self class primitiveFailTokenFor: #'bad number of arguments'].
thisReceiver := arguments at: n - 2 ifAbsent: [receiver].
methodArg primitive > 0 ifTrue:
[methodArg isQuick ifTrue:
[^self push: (methodArg valueWithReceiver: thisReceiver arguments: args)].
^self doPrimitive: methodArg primitive method: meth receiver: thisReceiver args: args].
^Context
sender: self
receiver: thisReceiver
method: methodArg
arguments: args].
primitiveIndex = 118 ifTrue: "[receiver:]tryPrimitive:withArgs:; avoid recursing in the VM"
[(arguments size = 3
and: [(self objectClass: arguments second) == SmallInteger
and: [(self objectClass: arguments last) == Array]]) ifTrue:
[^self doPrimitive: arguments second method: meth receiver: arguments first args: arguments last].
(arguments size = 2
and: [(self objectClass: arguments first) == SmallInteger
and: [(self objectClass: arguments last) == Array]]) ifFalse:
[^self class primitiveFailTokenFor: nil].
^self doPrimitive: arguments first method: meth receiver: receiver args: arguments last].
value := primitiveIndex = 120 "FFI method"
ifTrue: [(meth literalAt: 1) tryInvokeWithArguments: arguments]
ifFalse:
[primitiveIndex = 117 "named primitives"
ifTrue: [self tryNamedPrimitiveIn: meth for: receiver withArgs: arguments]
ifFalse: "should use self receiver: receiver tryPrimitive: primitiveIndex withArgs: arguments but this is only in later VMs (and appears to be broken)"
[receiver tryPrimitive: primitiveIndex withArgs: arguments]].
^(self isPrimFailToken: value)
ifTrue: [value]
ifFalse: [self push: value]!
Marcel Taeumel uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-mt.1383.mcz
==================== Summary ====================
Name: Kernel-mt.1383
Author: mt
Time: 26 March 2021, 12:51:18.904073 pm
UUID: 524a87b1-28d6-f044-8a9a-4ca045211ac1
Ancestors: Kernel-ct.1382
Merges Kernel-ct.1382
=============== Diff against Kernel-mt.1381 ===============
Item was changed:
----- Method: BlockClosure>>newProcess (in category 'scheduling') -----
newProcess
+ "Answer a Process running the code in the receiver. The process is not scheduled."
- "Answer a Process running the code in the receiver. The process is not
- scheduled."
- <primitive: 19> "Simulation guard"
^Process
forContext:
[self value.
+ "Since control is now at the bottom, there is no need to terminate (which runs unwinds) since all unwinds have been run. Simply suspend.
+ 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."
- "Since control is now at the bottom there is no need to terminate (which
- runs unwinds) since all unwnds have been run. Simply suspend.
- 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."
Processor activeProcess suspend] asContext
priority: Processor activePriority!
Item was changed:
----- Method: BlockClosure>>newProcessWith: (in category 'scheduling') -----
newProcessWith: anArray
+ "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."
- "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."
- <primitive: 19> "Simulation guard"
^Process
forContext:
[self valueWithArguments: anArray.
+ "Since control is now at the bottom, there is no need to terminate (which runs unwinds) since all unwinds have been run. Simply suspend.
+ 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."
- "Since control is now at the bottom there is no need to terminate (which
- runs unwinds) since all unwnds have been run. Simply suspend.
- 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."
Processor activeProcess suspend] asContext
priority: Processor activePriority!
Item was changed:
----- Method: Context>>doPrimitive:method:receiver:args: (in category 'private') -----
doPrimitive: primitiveIndex method: meth receiver: receiver args: arguments
"Simulate a primitive method whose index is primitiveIndex. The simulated receiver and
arguments are given as arguments to this message. If successful, push result and return
resuming context, else ^ {errCode, PrimitiveFailToken}. Any primitive which provokes
execution needs to be intercepted and simulated to avoid execution running away."
| value |
"Judicious use of primitive 19 (a null primitive that doesn't do anything) prevents
the debugger from entering various run-away activities such as spawning a new
process, etc. Injudicious use results in the debugger not being able to debug
interesting code, such as the debugger itself. Hence use primitive 19 with care :-)"
"SystemNavigation new browseAllSelect: [:m| m primitive = 19]"
+ (primitiveIndex = 19 or: [primitiveIndex >= 85 and: [primitiveIndex <= 88] "control primitives"]) ifTrue: [
- primitiveIndex = 19 ifTrue: [
[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})]
ifCurtailed: [self push: nil "Cheap fix of the context's internal state"]].
((primitiveIndex between: 201 and: 222)
and: [(self objectClass: receiver) includesBehavior: BlockClosure]) ifTrue:
[(primitiveIndex = 206
or: [primitiveIndex = 208]) ifTrue: "[Full]BlockClosure>>valueWithArguments:"
[^receiver simulateValueWithArguments: arguments first caller: self].
((primitiveIndex between: 201 and: 209) "[Full]BlockClosure>>value[:value:...]"
or: [primitiveIndex between: 221 and: 222]) ifTrue: "[Full]BlockClosure>>valueNoContextSwitch[:]"
[^receiver simulateValueWithArguments: arguments caller: self]].
primitiveIndex = 83 ifTrue: "afr 9/11/1998 19:50" "Object>>perform:[with:...]"
[^self send: arguments first to: receiver with: arguments allButFirst].
primitiveIndex = 84 ifTrue: "afr 9/11/1998 19:50 & eem 8/18/2009 17:04" "Object>>perform:withArguments:"
[^self send: arguments first to: receiver with: (arguments at: 2) lookupIn: (self objectClass: receiver)].
primitiveIndex = 100 ifTrue: "eem 8/18/2009 16:57" "Object>>perform:withArguments:inSuperclass:"
[^self send: arguments first to: receiver with: (arguments at: 2) lookupIn: (arguments at: 3)].
"Mutex>>primitiveEnterCriticalSection
Mutex>>primitiveTestAndSetOwnershipOfCriticalSection"
(primitiveIndex = 186 or: [primitiveIndex = 187]) ifTrue:
+ [value := primitiveIndex = 186
+ ifTrue: [receiver primitiveEnterCriticalSectionOnBehalfOf: Processor activeProcess]
+ ifFalse: [receiver primitiveTestAndSetOwnershipOfCriticalSectionOnBehalfOf: Processor activeProcess].
- [| effective |
- effective := Processor activeProcess effectiveProcess.
- "active == effective"
- value := primitiveIndex = 186
- ifTrue: [receiver primitiveEnterCriticalSectionOnBehalfOf: effective]
- ifFalse: [receiver primitiveTestAndSetOwnershipOfCriticalSectionOnBehalfOf: effective].
^(self isPrimFailToken: value)
ifTrue: [value]
ifFalse: [self push: value]].
primitiveIndex = 188 ifTrue: "Object>>withArgs:executeMethod:
CompiledMethod class>>receiver:withArguments:executeMethod:
VMMirror>>ifFail:object:with:executeMethod: et al"
[| n args methodArg thisReceiver |
((n := arguments size) between: 2 and: 4) ifFalse:
[^self class primitiveFailTokenFor: #'unsupported operation'].
((self objectClass: (args := arguments at: n - 1)) == Array
and: [(self objectClass: (methodArg := arguments at: n)) includesBehavior: CompiledMethod]) ifFalse:
[^self class primitiveFailTokenFor: #'bad argument'].
methodArg numArgs = args size ifFalse:
[^self class primitiveFailTokenFor: #'bad number of arguments'].
thisReceiver := arguments at: n - 2 ifAbsent: [receiver].
methodArg primitive > 0 ifTrue:
[methodArg isQuick ifTrue:
[^self push: (methodArg valueWithReceiver: thisReceiver arguments: args)].
^self doPrimitive: methodArg primitive method: meth receiver: thisReceiver args: args].
^Context
sender: self
receiver: thisReceiver
method: methodArg
arguments: args].
primitiveIndex = 118 ifTrue: "[receiver:]tryPrimitive:withArgs:; avoid recursing in the VM"
[(arguments size = 3
and: [(self objectClass: arguments second) == SmallInteger
and: [(self objectClass: arguments last) == Array]]) ifTrue:
[^self doPrimitive: arguments second method: meth receiver: arguments first args: arguments last].
(arguments size = 2
and: [(self objectClass: arguments first) == SmallInteger
and: [(self objectClass: arguments last) == Array]]) ifFalse:
[^self class primitiveFailTokenFor: nil].
^self doPrimitive: arguments first method: meth receiver: receiver args: arguments last].
value := primitiveIndex = 120 "FFI method"
ifTrue: [(meth literalAt: 1) tryInvokeWithArguments: arguments]
ifFalse:
[primitiveIndex = 117 "named primitives"
ifTrue: [self tryNamedPrimitiveIn: meth for: receiver withArgs: arguments]
ifFalse: "should use self receiver: receiver tryPrimitive: primitiveIndex withArgs: arguments but this is only in later VMs (and appears to be broken)"
[receiver tryPrimitive: primitiveIndex withArgs: arguments]].
^(self isPrimFailToken: value)
ifTrue: [value]
ifFalse: [self push: value]!