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

commits at source.squeak.org commits at source.squeak.org
Thu May 7 17:16:10 UTC 2015


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

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

Name: Cog-eem.263
Author: eem
Time: 7 May 2015, 10:15:56.515 am
UUID: f308cadc-bc13-46e4-8ac7-16c638330867
Ancestors: Cog-eem.262

Spur Bootstrap:
Don't use the standard instance creation protocol
for MCMethod/ClassDefinition instances which uses
instanceLike:, sicne this could create unintended
sharing.

=============== Diff against Cog-eem.262 ===============

Item was changed:
  ----- Method: SpurBootstrapMonticelloPackagePatcher>>classDefinitionFor:type:from:comment:stamp: (in category 'private-accessing') -----
  classDefinitionFor: className type: typeSymbol from: definitions comment: commentString stamp: stampString
  	| classDef |
  	classDef := definitions
  					detect: [:d| d isClassDefinition and: [d className = className]]
  					ifNone:
  						[self assert: (#(BoxedFloat64 SmallFloat64) includes: className).
+ 						 MCClassDefinition new
+ 							initializeWithName: className
- 						 MCClassDefinition
- 							name: className
  							superclassName: #Float
  							traitComposition: '{}'
  							classTraitComposition: '{}'
  							category: 'Kernel-Numbers'
  							instVarNames: #()
  							classVarNames: #()
  							poolDictionaryNames: #()
  							classInstVarNames: #()
  							type: typeSymbol
  							comment: commentString asString
  							commentStamp: stampString].
  	className == #Character ifTrue:
  		[classDef variables removeAllSuchThat:
  			[:varDef|
  			 varDef isInstanceVariable and: [varDef name = 'value']]].
  	classDef instVarNamed: 'type' put: typeSymbol.
  	commentString ifNotNil:
  		[classDef
  			instVarNamed: 'comment' put: commentString;
  			instVarNamed: 'commentStamp' put: stampString].
  	^MCAddition of: classDef!

Item was changed:
  ----- Method: SpurBootstrapMonticelloPackagePatcher>>compiledMethodClassDefinition (in category 'private-accessing') -----
  compiledMethodClassDefinition
  	^MCAddition of: 
+ 		(MCClassDefinition new
+ 			initializeWithName: #CompiledMethod
- 		(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:
  
  	(index 0)		15 bits:	number of literals (#numLiterals)
  	(index 15)		  1 bit:	is optimized - reserved for methods that have been optimized by Sista
  	(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)
  
  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')!

Item was changed:
  ----- Method: SpurBootstrapMonticelloPackagePatcher>>modifiedFloatDefinitionsIn: (in category 'private-accessing') -----
  modifiedFloatDefinitionsIn: definitions
  	"Delete the non-accessing primitives in Float (prims 41 through 59),
  	 and copy them to BoxedFloat64,
  	 and create corresponding ones in SmallFloat64 with primtiive numbers + 500."
  	| floatPrims |
  	floatPrims := definitions select:
  					[:d| | index |
  					d isMethodDefinition
  					and: [d fullClassName = #Float
  					and: [(index := d source indexOfSubCollection: '<primitive: ') > 0
  					and: [(Integer readFrom: (ReadStream on: d source from: index + '<primitive: ' size to: index + '<primitive: ' size + 4))
  							between: 41
  							and: 59]]]].
  	^(floatPrims collect:
  		[:d|
+ 		 MCMethodDefinition new
+ 			initializeWithClassName: d className
- 		 MCMethodDefinition 
- 			className: d className
  			classIsMeta: false
  			selector: d selector
  			category: d category
  			timeStamp: d timeStamp
  			source: d source, 'DELETEME']),
  	 (floatPrims collect:
  		[:d|
+ 		 MCMethodDefinition new
+ 			initializeWithClassName: #BoxedFloat64
- 		 MCMethodDefinition 
- 			className: #BoxedFloat64
  			classIsMeta: false
  			selector: d selector
  			category: d category
  			timeStamp: d timeStamp
  			source: d source]),
  	 (floatPrims collect:
  		[:d|
+ 		 MCMethodDefinition new
+ 			initializeWithClassName: #SmallFloat64
- 		 MCMethodDefinition 
- 			className: #SmallFloat64
  			classIsMeta: false
  			selector: d selector
  			category: d category
  			timeStamp: 'eem 11/25/2014 07:54'
  			source: (d source copyReplaceAll: '<primitive: ' with: '<primitive: 5')])!

Item was changed:
  ----- Method: SpurBootstrapMonticelloPackagePatcher>>packagesAndPatches (in category 'private-accessing') -----
  packagesAndPatches
  	"SpurBootstrapMonticelloPackagePatcher new packagesAndPatches"
  	| spurBootstrap |
  	packagesAndPatches ifNotNil:
  		[^packagesAndPatches].
  	packagesAndPatches := Dictionary new.
  	spurBootstrap := SpurBootstrap new.
  	imageTypes ifNotNil:
  		[spurBootstrap imageTypes: imageTypes].
  	spurBootstrap prototypeClassNameMetaSelectorMethodDo:
  		[:className :isMeta :selector :method| | package category source definition |
  		 (Smalltalk classNamed: className)
  			ifNil: [package := self packageForMissingClassNamed: className]
  			ifNotNil:
  				[:behavior| | class methodReference |
  				 class := isMeta ifTrue: [behavior class] ifFalse: [behavior].
  				 (class includesSelector: selector) ifTrue:
  					[methodReference := (class >> selector) methodReference.
  					 category := methodReference category].
  				 package := (methodReference isNil
  							  or: [methodReference category = Categorizer default])
  								ifTrue: [PackageOrganizer default packageOfClass: class]
  								ifFalse: [PackageOrganizer default packageOfMethod: methodReference]].
  		 source := method getSourceFromFile asString allButFirst: method selector size - selector size.
  		 source first ~= selector first ifTrue:
  			[source replaceFrom: 1 to: selector size with: selector startingAt: 1].
+ 		 definition := MCAddition of: (MCMethodDefinition new
+ 										initializeWithClassName: className
- 		 definition := MCAddition of: (MCMethodDefinition
- 										className: className
  										classIsMeta: isMeta
  										selector: selector
  										category: (category ifNil: [SpurBootstrap
  																	categoryForClass: className
  																	meta: isMeta
  																	selector: selector])
  										timeStamp: method timeStamp
  										source: source).
  		 (method pragmaAt: #remove) ifNotNil:
  			[definition := definition inverse].
  		 (packagesAndPatches at: package ifAbsentPut: [OrderedCollection new])
  			add: definition].
  	^packagesAndPatches!

Item was changed:
  ----- Method: SpurBootstrapMonticelloPackagePatcher>>patchDefinition:withRewriter: (in category 'patching') -----
  patchDefinition: aMCMethodDefinition withRewriter: aRBParseTreeRewriter 
  	| parseTree |
  	parseTree := RBParser
  					parseMethod: aMCMethodDefinition source
  					onError: [:str :pos | self halt].
  	aRBParseTreeRewriter executeTree: parseTree.
+ 	^MCMethodDefinition new
+ 		initializeWithClassName: aMCMethodDefinition className
- 	^MCMethodDefinition 
- 		className: aMCMethodDefinition className
  		classIsMeta:aMCMethodDefinition classIsMeta
  		selector: aMCMethodDefinition selector
  		category: aMCMethodDefinition category
  		timeStamp: aMCMethodDefinition timeStamp
  		source: aRBParseTreeRewriter tree newSource!



More information about the Vm-dev mailing list