[Vm-dev] VM Maker: Cog-eem.143.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Mar 12 18:48:50 UTC 2014


Eliot Miranda uploaded a new version of Cog to project VM Maker:
http://source.squeak.org/VMMaker/Cog-eem.143.mcz

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

Name: Cog-eem.143
Author: eem
Time: 11 March 2014, 6:47:12.007 pm
UUID: 4be02abd-37dc-4243-b303-fa4a6efe12b6
Ancestors: Cog-eem.142

Add the spiffy new allInstaces/allObjects primitives and surrounding
code to the Spur booitstrap.  Assumes MMaker.oscog-eem.638.

=============== Diff against Cog-eem.142 ===============

Item was added:
+ ----- Method: SpurBootstrap class>>BehaviorPROTOTYPEallInstances (in category 'method prototypes') -----
+ BehaviorPROTOTYPEallInstances
+ 	"Answer all instances of the receiver."
+ 	<primitive: 177>
+ 	"The primitive can fail because memory is low.  If so, fall back on the old
+ 	 enumeration code, which gives the system a chance to GC and/or grow.
+ 	 Because aBlock might change the class of inst (for example, using become:),
+ 	 it is essential to compute next before aBlock value: inst."
+ 	| inst insts next |
+ 	insts := WriteStream on: (Array new: 64).
+ 	inst := self someInstance.
+ 	[inst == nil] whileFalse:
+ 		[next := inst nextInstance.
+ 		 (inst == insts or: [inst == insts originalContents]) ifFalse: [insts nextPut: inst].
+ 		 inst := next].
+ 	^insts contents!

Item was added:
+ ----- Method: SpurBootstrap class>>BehaviorPROTOTYPEallInstancesDo: (in category 'method prototypes') -----
+ BehaviorPROTOTYPEallInstancesDo: aBlock
+ 	"Evaluate aBlock with each of the current instances of the receiver."
+ 	| instances inst next |
+ 	instances := self allInstancesOrNil.
+ 	instances ifNotNil:
+ 		[instances do: aBlock.
+ 		 ^self].
+ 	"allInstancesOrNil can fail because memory is low.  If so, fall back on the old
+ 	 enumeration code.  Because aBlock might change the class of inst (for example,
+ 	 using become:), it is essential to compute next before aBlock value: inst."
+ 	inst := self someInstance.
+ 	[inst == nil] whileFalse:
+ 		[next := inst nextInstance.
+ 		 aBlock value: inst.
+ 		 inst := next]!

Item was added:
+ ----- Method: SpurBootstrap class>>BehaviorPROTOTYPEallInstancesOrNil (in category 'method prototypes') -----
+ BehaviorPROTOTYPEallInstancesOrNil
+ 	"Answer all instances of the receiver, or nil if the primitive
+ 	 fails, which it may be due to being out of memory."
+ 	<primitive: 177>
+ 	^nil!

Item was added:
+ ----- Method: SpurBootstrap class>>MethodContextPROTOTYPEallInstances (in category 'method prototypes') -----
+ MethodContextPROTOTYPEallInstances
+ 	"Answer all instances of the receiver."
+ 	<primitive: 177>
+ 	"The primitive can fail because memory is low.  If so, fall back on the old
+ 	 enumeration code, which gives the system a chance to GC and/or grow.
+ 	 Because aBlock might change the class of inst (for example, using become:),
+ 	 it is essential to compute next before aBlock value: inst.
+ 	 Only count until thisContext since this context has been created only to
+ 	 compute the existing instances."
+ 	| inst insts next |
+ 	insts := WriteStream on: (Array new: 64).
+ 	inst := self someInstance.
+ 	[inst == thisContext or: [inst == nil]] whileFalse:
+ 		[next := inst nextInstance.
+ 		 insts nextPut: inst.
+ 		 inst := next].
+ 	^insts contents!

Item was added:
+ ----- Method: SpurBootstrap class>>MethodContextPROTOTYPEallInstancesDo: (in category 'method prototypes') -----
+ MethodContextPROTOTYPEallInstancesDo: aBlock
+ 	"Evaluate aBlock with each of the current instances of the receiver."
+ 	| instances inst next |
+ 	instances := self allInstancesOrNil.
+ 	instances ifNotNil:
+ 		[instances do: aBlock.
+ 		 ^self].
+ 	"allInstancesOrNil can fail because memory is low.  If so, fall back on the old
+ 	 enumeration code.  Because aBlock might change the class of inst (for example,
+ 	 using become:), it is essential to compute next before aBlock value: inst.
+ 	 Only count until thisContext since evaluation of aBlock will create new contexts."
+ 	inst := self someInstance.
+ 	[inst == thisContext or: [inst == nil]] whileFalse:
+ 		[next := inst nextInstance.
+ 		 aBlock value: inst.
+ 		 inst := next]!

Item was added:
+ ----- Method: SpurBootstrap class>>SystemNavigationPROTOTYPEallObjects (in category 'method prototypes') -----
+ SystemNavigationPROTOTYPEallObjects
+ 	"Answer an Array of all objects in the system.  Fail if
+ 	 there isn't enough memory to instantiate the result."
+ 	<primitive: 178>
+ 	^self primitiveFailed!

Item was added:
+ ----- Method: SpurBootstrap class>>SystemNavigationPROTOTYPEallObjectsDo: (in category 'method prototypes') -----
+ SystemNavigationPROTOTYPEallObjectsDo: aBlock 
+ 	"Evaluate the argument, aBlock, for each object in the system, excluding immediates
+ 	 such as SmallInteger and Character."
+ 	self allObjectsOrNil
+ 		ifNotNil: [:allObjects| allObjects do: aBlock]
+ 		ifNil:
+ 			["Fall back on the old single object primitive code.  With closures, this needs
+ 			  to use an end marker (lastObject) since activation of the block will create
+ 			  new contexts and cause an infinite loop.  The lastObject must be created
+ 			  before calling someObject, so that the VM can settle the enumeration (e.g.
+ 			  by flushing new space) as a side effect of  someObject"
+ 			| object lastObject |
+ 			lastObject := Object new.
+ 			object := self someObject.
+ 			[lastObject == object or: [0 == object]] whileFalse:
+ 				[aBlock value: object.
+ 				 object := object nextObject]]!

Item was added:
+ ----- Method: SpurBootstrap class>>SystemNavigationPROTOTYPEallObjectsOrNil (in category 'method prototypes') -----
+ SystemNavigationPROTOTYPEallObjectsOrNil
+ 	"Answer an Array of all objects in the system.  Fail if there isn't
+ 	 enough memory to instantiate the result and answer nil."
+ 	<primitive: 178>
+ 	^nil!



More information about the Vm-dev mailing list