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

commits at source.squeak.org commits at source.squeak.org
Tue Jan 27 00:43:35 UTC 2015


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

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

Name: Cog-eem.236
Author: eem
Time: 26 January 2015, 4:43:21.829 pm
UUID: 9be16033-ecdb-4b44-a2c5-21ad741d334d
Ancestors: Cog-eem.235

Spur Bootstrap:
Reduce the max num literals to 32k and use the bit to mark optimised
methods for Sista.

64-bit ize Large[Nega|Posi]tiveInteger>>normalize and
SmallInteger>>digitLength.

=============== Diff against Cog-eem.235 ===============

Item was changed:
  ----- Method: SpurBootstrapMonticelloPackagePatcher>>compiledMethodClassDefinition (in category 'private-accessing') -----
  compiledMethodClassDefinition
  	^MCAddition of: 
  		(MCClassDefinition name: #CompiledMethod
  			superclassName: #ByteArray
  			category: #'Kernel-Methods'
  			instVarNames: #()
  			classVarNames: #(LargeFrame PrimaryBytecodeSetEncoderClass SecondaryBytecodeSetEncoderClass SmallFrame)
  			poolDictionaryNames: #()
  			classInstVarNames: #()
  			type: #compiledMethod
  			comment:
  'CompiledMethod instances are methods suitable for interpretation by the virtual machine.  Instances of CompiledMethod and its subclasses are the only objects in the system that have both indexable pointer fields and indexable 8-bit integer fields.  The first part of a CompiledMethod is pointers, the second part is bytes.  CompiledMethod inherits from ByteArray to avoid duplicating some of ByteArray''s methods, not because a CompiledMethod is-a ByteArray.
  
  Class variables:
  SmallFrame								- the number of stack slots in a small frame Context
  LargeFrame							- the number of stack slots in a large frame Context
  PrimaryBytecodeSetEncoderClass		- the encoder class that defines the primary instruction set
  SecondaryBytecodeSetEncoderClass	- the encoder class that defines the secondary instruction set
  
  The current format of a CompiledMethod is as follows:
  
  	header (4 or 8 bytes, SmallInteger)
  	literals (4 or 8 bytes each, Object, see "The last literal..." below)
  	bytecodes  (variable, bytes)
  	trailer (variable, bytes)
  
+ The header is a SmallInteger (which in the 32-bit system has 31 bits, and in the 64-bit system, 61 bits) in the following format:
- The header is a 31-bit signed integer (a SmallInteger) in the following format:
  
+ 	(index 0)		15 bits:	number of literals (#numLiterals)
+ 	(index 15)		  1 bit:	is optimized - reserved for methods that have been optimized by Sista
- 	(index 0)		16 bits:	number of literals (#numLiterals)
  	(index 16)		  1 bit:	has primitive
  	(index 17)		  1 bit:	whether a large frame size is needed (#frameSize => either SmallFrame or LargeFrame)
  	(index 18)		  6 bits:	number of temporary variables (#numTemps)
  	(index 24)		  4 bits:	number of arguments to the method (#numArgs)
  	(index 28)		  2 bits:	reserved for an access modifier (00-unused, 01-private, 10-protected, 11-public), although accessors for bit 29 exist (see #flag).
+ 	sign bit:			  1 bit: selects the instruction set, >= 0 Primary, < 0 Secondary (#signFlag)
- 	(index 30/63)	sign bit: 1 selects the Secondary instruction set (e.g. NewsqueakV4, 0 selects the primary instruction set, e.g. SqueakV3PlusClosures) (#signFlag)
  
  If the method has a primitive then the first bytecode of the method must be a callPrimitive: bytecode that encodes the primitive index.
  
  The trailer is an encoding of an instance of CompiledMethodTrailer.  It is typically used to encode the index into the source files array of the method''s source, but may be used to encode other values, e.g. tempNames, source as a string, etc.  See the class CompiledMethodTrailer.
  
+ The last literal in a CompiledMethod must be its methodClassAssociation, a binding whose value is the class the method is installed in.  The methodClassAssociation is used to implement super sends.  If a method contains no super send then its methodClassAssociation may be nil (as would be the case for example of methods providing a pool of inst var accessors).  By convention the penultimate literal of a method is either its selector or an instance of AdditionalMethodState.  AdditionalMethodState holds any pragmas and properties of a method, but may also be used to add instance variables to a method, albeit ones held in the method''s AdditionalMethodState.  Subclasses of CompiledMethod that want to add state should subclass AdditionalMethodState to add the state they want, and implement methodPropertiesClass on the class side of the CompiledMethod subclass to answer the specialized subclass of AdditionalMethodState.'
+ 			commentStamp: 'eem 1/22/2015 15:47')!
- The last literal in a CompiledMethod must be its methodClassAssociation, a binding whose value is the class the method is installed in.  The methodClassAssociation is used to implement super sends.  If a method contains no super send then its methodClassAssociation may be left nil (as would be the case for example of methods providing a pool of inst var accessors).  By convention the penultimate literal of a method is either its selector or an instance of AdditionalMethodState.  AdditionalMethodState holds any pragmas and properties of a method, but may also be used to add instance variables to a method, albeit ones held in the method''s AdditionalMethodState.  Subclasses of CompiledMethod that want to add state should subclass AdditionalMethodState to add the state they want, and implement methodPropertiesClass on the class side of the CompiledMethod subclass to answer the specialized subclass of AdditionalMethodState.'
- 			commentStamp: 'eem 8/12/2014 14:45')!

Item was changed:
  ----- Method: SpurBootstrapPrototypes>>CompiledMethodPROTOTYPEnumLiterals (in category 'method prototypes') -----
  CompiledMethodPROTOTYPEnumLiterals
  	"Answer the number of literals used by the receiver."
+ 	^self header bitAnd: 16r7FFF!
- 	^self header bitAnd: 65535!

Item was added:
+ ----- Method: SpurBootstrapPrototypes>>LargeNegativeIntegerPROTOTYPEnormalize (in category 'method prototypes') -----
+ LargeNegativeIntegerPROTOTYPEnormalize
+ 	"Check for leading zeroes and return shortened copy if so"
+ 	| sLen val len oldLen minVal |
+ 	<primitive: 'primNormalizeNegative' module: 'LargeIntegers'>
+ 	"First establish len = significant length"
+ 	len := oldLen := self digitLength.
+ 	[len = 0 ifTrue: [^0].
+ 	(self digitAt: len) = 0]
+ 		whileTrue: [len := len - 1].
+ 
+ 	"Now check if in SmallInteger range.
+ 	 Fast compute SmallInteger minVal digitLength"
+ 	sLen := SmallInteger minVal < -16r40000000
+ 				ifTrue: [8]
+ 				ifFalse: [4].
+ 	len <= sLen ifTrue:
+ 		[minVal := SmallInteger minVal.
+ 		(len < sLen
+ 		 or: [(self digitAt: sLen) < minVal lastDigit])
+ 			ifTrue: ["If high digit less, then can be small"
+ 					val := 0.
+ 					len to: 1 by: -1 do:
+ 						[:i | val := (val *256) - (self digitAt: i)].
+ 					^ val].
+ 		1 to: sLen do:  "If all digits same, then = minVal"
+ 			[:i | (self digitAt: i) = (minVal digitAt: i)
+ 					ifFalse: ["Not so; return self shortened"
+ 							len < oldLen
+ 								ifTrue: [^ self growto: len]
+ 								ifFalse: [^ self]]].
+ 		^ minVal].
+ 
+ 	"Return self, or a shortened copy"
+ 	len < oldLen
+ 		ifTrue: [^ self growto: len]
+ 		ifFalse: [^ self]!

Item was added:
+ ----- Method: SpurBootstrapPrototypes>>LargePositiveIntegerPROTOTYPEnormalize (in category 'method prototypes') -----
+ LargePositiveIntegerPROTOTYPEnormalize
+ 	"Check for leading zeroes and return shortened copy if so"
+ 	| sLen val len oldLen |
+ 	<primitive: 'primNormalizePositive' module:'LargeIntegers'>
+ 	"First establish len = significant length"
+ 	len := oldLen := self digitLength.
+ 	[len = 0 ifTrue: [^0].
+ 	(self digitAt: len) = 0]
+ 		whileTrue: [len := len - 1].
+ 
+ 	"Now check if in SmallInteger range.  Fast compute SmallInteger maxVal digitLength"
+ 	sLen := SmallInteger maxVal > 16r3FFFFFFF
+ 				ifTrue: [8]
+ 				ifFalse: [4].
+ 	(len <= sLen
+ 	 and: [(self digitAt: sLen) <= (SmallInteger maxVal digitAt: sLen)])
+ 		ifTrue: ["If so, return its SmallInt value"
+ 				val := 0.
+ 				len to: 1 by: -1 do:
+ 					[:i | val := (val *256) + (self digitAt: i)].
+ 				^ val].
+ 
+ 	"Return self, or a shortened copy"
+ 	len < oldLen
+ 		ifTrue: [^ self growto: len]
+ 		ifFalse: [^ self]!

Item was added:
+ ----- Method: SpurBootstrapPrototypes>>SmallIntegerPROTOTYPEdigitLength (in category 'method prototypes') -----
+ SmallIntegerPROTOTYPEdigitLength
+ 	"Answer the number of indexable fields in the receiver. This value is the 
+ 	 same as the largest legal subscript. Included so that a SmallInteger can 
+ 	 behave like a LargePositiveInteger or LargeNegativeInteger."
+ 
+ 	| value length |
+ 	length := 1.
+ 	value := self.
+ 	value >= 0
+ 		ifTrue:
+ 			[[value > 255] whileTrue:
+ 				[value := value bitShift: -8.
+ 				 length := length + 1]]
+ 		ifFalse:
+ 			[[value < -255] whileTrue:
+ 				[value := value bitShift: -8.
+ 				 length := length + 1]].
+ 	^length!



More information about the Vm-dev mailing list