[squeak-dev] The Trunk: Collections-eem.881.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Mar 12 01:53:53 UTC 2020


Eliot Miranda uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-eem.881.mcz

==================== Summary ====================

Name: Collections-eem.881
Author: eem
Time: 11 March 2020, 6:53:50.254027 pm
UUID: 012691b6-410a-4e9a-9c64-97b5abfdba49
Ancestors: Collections-eem.880

Include the Array bulk-become machinery in the ModificationForbidden framework.

=============== Diff against Collections-eem.880 ===============

Item was changed:
  ----- Method: Array>>elementsExchangeIdentityWith: (in category 'converting') -----
  elementsExchangeIdentityWith: otherArray
  	"This primitive performs a bulk mutation, causing all pointers to the elements of the
  	 receiver to be replaced by pointers to the corresponding elements of otherArray.
  	 At the same time, all pointers to the elements of otherArray are replaced by
  	 pointers to the corresponding elements of this array.  The identityHashes remain
  	 with the pointers rather than with the objects so that objects in hashed structures
  	 should still be properly indexed after the mutation."
  
  	<primitive: 128 error: ec>
+ 	ec == #'no modification' ifTrue:
+ 		[^self modificationForbiddenFor: otherArray becomeSelector: #elementsExchangeIdentityWith:].
  	ec == #'bad receiver' ifTrue:
  		[^self error: 'receiver must be of class Array'].
  	ec == #'bad argument' ifTrue:
  		[^self error: (otherArray class == Array
  						ifTrue: ['arg must be of class Array']
  						ifFalse: ['receiver and argument must have the same size'])].
  	ec == #'inappropriate operation' ifTrue:
  		[^self error: 'can''t become immediates such as SmallIntegers or Characters'].
- 	ec == #'no modification' ifTrue:
- 		[^self error: 'can''t become immutable objects'].
  	ec == #'object is pinned' ifTrue:
  		[^self error: 'can''t become pinned objects'].
  	ec == #'insufficient object memory' ifTrue:
  		[| maxRequired |
  		 "In Spur, two-way become may involve making each pair of objects into a forwarder into a copy of the other.
  		 So if become fails with #'insufficient object memory', garbage collect, and if necessary, grow memory."
  		 maxRequired := (self detectSum: [:obj | obj class byteSizeOfInstanceOfSize: obj basicSize])
  						+ (otherArray detectSum: [:obj | obj class byteSizeOfInstanceOfSize: obj basicSize]).
  		 (Smalltalk garbageCollectMost < maxRequired
  		  and: [Smalltalk garbageCollect < maxRequired]) ifTrue:
  			[Smalltalk growMemoryByAtLeast: maxRequired].
  		 ^self elementsExchangeIdentityWith: otherArray].
  	self primitiveFailed!

Item was changed:
  ----- Method: Array>>elementsForwardIdentityTo: (in category 'converting') -----
  elementsForwardIdentityTo: otherArray
  	"This primitive performs a bulk mutation, causing all pointers to the elements of the
  	 receiver to be replaced by pointers to the corresponding elements of otherArray.
  	 The identityHashes remain with the pointers rather than with the objects so that
  	 the objects in this array should still be properly indexed in any existing hashed
  	 structures after the mutation."
  	<primitive: 72 error: ec>
+ 	ec == #'no modification' ifTrue:
+ 		[^self modificationForbiddenFor: otherArray becomeSelector: #elementsForwardIdentityTo:].
  	ec == #'bad receiver' ifTrue:
  		[^self error: 'receiver must be of class Array'].
  	ec == #'bad argument' ifTrue:
  		[^self error: (otherArray class == Array
  						ifTrue: ['arg must be of class Array']
  						ifFalse: ['receiver and argument must have the same size'])].
  	ec == #'inappropriate operation' ifTrue:
  		[^self error: 'can''t become immediates such as SmallIntegers or Characters'].
- 	ec == #'no modification' ifTrue:
- 		[^self error: 'can''t become immutable objects'].
  	ec == #'object is pinned' ifTrue:
  		[^self error: 'can''t become pinned objects'].
  	ec == #'insufficient object memory' ifTrue:
  		[self error: 'The virtual machine is out-of-date.  Please upgrade.'].
  	self primitiveFailed!

Item was changed:
  ----- Method: Array>>elementsForwardIdentityTo:copyHash: (in category 'converting') -----
  elementsForwardIdentityTo: otherArray copyHash: copyHash
  	"This primitive performs a bulk mutation, causing all pointers to the elements of the
  	 receiver to be replaced by pointers to the corresponding elements of otherArray.
  	 If copyHash is true, the identityHashes remain with the pointers rather than with the
  	 objects so that the objects in the receiver should still be properly indexed in any
  	 existing hashed structures after the mutation.  If copyHash is false, then the hashes
  	 of the objects in otherArray remain unchanged.  If you know what you're doing this
  	 may indeed be what you want."
  	<primitive: 249 error: ec>
+ 	ec == #'no modification' ifTrue:
+ 		[^self modificationForbiddenFor: otherArray argument: copyHash becomeSelector: #elementsForwardIdentityTo:copyHash:].
  	ec == #'bad receiver' ifTrue:
  		[^self error: 'receiver must be of class Array'].
  	ec == #'bad argument' ifTrue:
  		[^self error: (otherArray class == Array
  						ifTrue: ['arg must be of class Array']
  						ifFalse: ['receiver and argument must have the same size'])].
  	ec == #'inappropriate operation' ifTrue:
  		[^self error: 'can''t become immediates such as SmallIntegers or Characters'].
- 	ec == #'no modification' ifTrue:
- 		[^self error: 'can''t become immutable objects'].
  	ec == #'object is pinned' ifTrue:
  		[^self error: 'can''t become pinned objects'].
  	self primitiveFailed!

Item was added:
+ ----- Method: Array>>modificationForbiddenFor:argument:becomeSelector: (in category 'read-only objects') -----
+ modificationForbiddenFor: otherArray argument: argument becomeSelector: retrySelector
+ 	"Raise a ModificationForbidden error for an attempt to modify a read-only object through a become operation."
+ 	^(ModificationForbidden new
+ 		mirror: self
+ 		object: otherArray
+ 		index: nil
+ 		newValue: argument
+ 		resumptionValue: self
+ 		retrySelector: retrySelector) signal!

Item was added:
+ ----- Method: Array>>modificationForbiddenFor:becomeSelector: (in category 'read-only objects') -----
+ modificationForbiddenFor: otherArray becomeSelector: retrySelector
+ 	"Raise a ModificationForbidden error for an attempt to modify a read-only object through a become operation."
+ 	^(BinaryModificationForbidden new
+ 		mirror: self
+ 		object: otherArray
+ 		index: nil
+ 		newValue: nil
+ 		resumptionValue: self
+ 		retrySelector: retrySelector) signal!



More information about the Squeak-dev mailing list