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

commits at source.squeak.org commits at source.squeak.org
Wed Aug 13 13:29:51 UTC 2014


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

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

Name: Cog-eem.188
Author: eem
Time: 13 August 2014, 6:29:34.276 am
UUID: 78c7c9fd-b406-4d1d-b025-3d091643cf38
Ancestors: Cog-eem.187

Use the error code in the basicNew[:] prototypes to simplify
error checking vs retry.
Add prototypes for CompiledMethod class>>
newMethod:header: and failing support.

=============== Diff against Cog-eem.187 ===============

Item was changed:
  ----- Method: SpurBootstrap class>>BehaviorPROTOTYPEbasicNew (in category 'method prototypes') -----
  BehaviorPROTOTYPEbasicNew
  	"Primitive. Answer an instance of the receiver (which is a class) with no 
  	 indexable variables. Fail if the class is indexable. Essential. See Object 
  	 documentation whatIsAPrimitive.
  	
  	 If the primitive fails because space is low then the scavenger
+ 	 will run before the method is activated.  Check that space was low and
+ 	 retry via handleFailingBasicNew if so."
- 	 will run before the method is activated.  Check arguments and
- 	 retry via handleFailingBasicNew if they're OK."
  
+ 	<primitive: 70 error: ec>
+ 	ec == #'insufficient object memory' ifTrue:
+ 		[^self handleFailingBasicNew].
- 	<primitive: 70>
  	self isVariable ifTrue: [^self basicNew: 0].
+ 	self primitiveFailed!
- 	"space must have been low, and the scavenger must have run.
- 	 retry after the scavenge."
- 	^self handleFailingBasicNew!

Item was changed:
  ----- Method: SpurBootstrap class>>BehaviorPROTOTYPEbasicNew: (in category 'method prototypes') -----
+ BehaviorPROTOTYPEbasicNew: sizeRequested
- BehaviorPROTOTYPEbasicNew: sizeRequested 
  	"Primitive. Answer an instance of this class with the number of indexable
  	 variables specified by the argument, sizeRequested.  Fail if this class is not
  	 indexable or if the argument is not a positive Integer, or if there is not
  	 enough memory available. Essential. See Object documentation whatIsAPrimitive.
  	
  	 If the primitive fails because space is low then the scavenger will run before the
  	 method is activated.  Check args and retry via handleFailingBasicNew: if they're OK."
  
+ 	<primitive: 71 error: ec>
+ 	ec == #'insufficient object memory' ifTrue:
+ 		[^self handleFailingBasicNew: sizeRequested].
- 	<primitive: 71>
  	self isVariable ifFalse:
  		[self error: self printString, ' cannot have variable sized instances'].
- 	(sizeRequested isInteger and: [sizeRequested >= 0]) ifTrue:
- 		["arg okay; space must have been low, and the scavenger must have run.
- 		  retry after the scavenge"
- 		^self handleFailingBasicNew: sizeRequested].
  	self primitiveFailed!

Item was added:
+ ----- Method: SpurBootstrap class>>CompiledMethodPROTOTYPEhandleFailingFailingNewMethod:header: (in category 'method prototypes') -----
+ CompiledMethodPROTOTYPEhandleFailingFailingNewMethod: numberOfBytes header: headerWord
+ 	"This newMethod:header: gets sent after handleFailingBasicNew: has done a full
+ 	 garbage collection and possibly grown memory.  If this basicNew: fails then the
+ 	 system really is low on space, so raise the OutOfMemory signal.
+ 
+ 	 Primitive. Answer an instance of this class with the number of indexable variables
+ 	 specified by the argument, headerWord, and the number of bytecodes specified
+ 	 by numberOfBytes.  Fail if this if the arguments are not Integers, or if numberOfBytes
+ 	 is negative, or if the receiver is not a CompiledMethod class, or if there is not enough
+ 	 memory available. Essential. See Object documentation whatIsAPrimitive."
+ 
+ 	<primitive: 79>
+ 	"space must be low."
+ 	OutOfMemory signal.
+ 	"retry if user proceeds"
+ 	^self newMethod: numberOfBytes header: headerWord!

Item was added:
+ ----- Method: SpurBootstrap class>>CompiledMethodPROTOTYPEhandleFailingNewMethod:header: (in category 'method prototypes') -----
+ CompiledMethodPROTOTYPEhandleFailingNewMethod: numberOfBytes header: headerWord
+ 	"This newMethod:header: gets sent after newMethod:header: has failed
+ 	 and allowed a scavenging garbage collection to occur.  The scavenging
+ 	 collection will have happened as the VM is activating the (failing) basicNew:.
+ 	 If handleFailingBasicNew: fails then the scavenge failed to reclaim sufficient
+ 	 space and a global garbage collection is required.  Retry after garbage
+ 	 collecting and growing memory if necessary.
+ 
+ 	 Primitive. Answer an instance of this class with the number of indexable variables
+ 	 specified by the argument, headerWord, and the number of bytecodes specified
+ 	 by numberOfBytes.  Fail if this if the arguments are not Integers, or if numberOfBytes
+ 	 is negative, or if the receiver is not a CompiledMethod class, or if there is not enough
+ 	 memory available. Essential. See Object documentation whatIsAPrimitive."
+ 
+ 	<primitive: 79>
+ 	| bytesRequested |
+ 	bytesRequested := (headerWord bitAnd: 16rFFFF) + 1 * Smalltalk wordSize + numberOfBytes + 16.
+ 	Smalltalk garbageCollect < bytesRequested ifTrue:
+ 		[Smalltalk growMemoryByAtLeast: bytesRequested].
+ 	"retry after global garbage collect and possible grow"
+ 	^self handleFailingFailingNewMethod: numberOfBytes header: headerWord!

Item was added:
+ ----- Method: SpurBootstrap class>>CompiledMethodPROTOTYPEnewMethod:header: (in category 'method prototypes') -----
+ CompiledMethodPROTOTYPEnewMethod: numberOfBytes header: headerWord
+ 	"Primitive. Answer an instance of me. The number of literals (and other 
+ 	 information) is specified by the headerWord (see my class comment).
+ 	 The first argument specifies the number of fields for bytecodes in the
+ 	 method. Fail if either argument is not a SmallInteger, or if numberOfBytes
+ 	 is negative, or if memory is low. Once the header of a method is set by
+ 	 this primitive, it cannot be changed to change the number of literals.
+ 	 Essential. See Object documentation whatIsAPrimitive."
+ 
+ 	<primitive: 79 error: ec>
+ 	ec == #'insufficient object memory' ifTrue:
+ 		[^self handleFailingNewMethod: numberOfBytes header: headerWord].
+ 	^self primitiveFailed!



More information about the Vm-dev mailing list