[Vm-dev] VM Maker: VMMaker.oscog-eem.983.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Dec 13 01:07:50 UTC 2014


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

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

Name: VMMaker.oscog-eem.983
Author: eem
Time: 12 December 2014, 5:04:57.172 pm
UUID: 4cdca841-6318-4c49-95de-8c47d0d7e91d
Ancestors: VMMaker.oscog-eem.982

and to avoid including positiveMachineIntegerFor:
et al in every plugin add a dead code removal pass.

Fix unreachableMethods to do a proper tramsitive
closure and answer methods instead of selectors.

=============== Diff against VMMaker.oscog-eem.982 ===============

Item was changed:
  ----- Method: ADPCMCodecPlugin class>>translateInDirectory:doInlining: (in category 'translation') -----
  translateInDirectory: directory doInlining: inlineFlag
  "handle a special case code string rather than generated code"
  "Not currently hooked into the timeStamp mechanism for VMMaker since this would mean replicating code from InterpreterPlugin; waiting for a more elegant solution to appear. In the meantime this means that this plugin will always get regenerated even if the file is uptodate"
  	| cg |
  	self initialize.
  
  	cg := self buildCodeGeneratorUpTo: InterpreterPlugin.
  
  	cg addMethodsForPrimitives: ADPCMCodec translatedPrimitives.
  	inlineFlag ifTrue:[
  		"now remove a few which will be inlined but not pruned"
  		cg pruneMethods: #(indexForDeltaFrom:to: nextBits: nextBits:put:)].
+ 	self pruneUnusedInterpreterPluginMethodsIn: cg.
  	self storeString: cg generateCodeStringForPrimitives onFileNamed: (directory fullNameFor: self moduleName, '.c').
  	^cg exportedPrimitiveNames asArray
  !

Item was changed:
  ----- Method: CCodeGenerator>>unreachableMethods (in category 'utilities') -----
  unreachableMethods
  	"Return a collection of methods that are never invoked."
  
+ 	| neededSelectors previousSize visited |
+ 	neededSelectors := Set new.
+ 	"collect the exports"
+ 	methods do:
+ 		[:m|
+ 		 m export ifTrue:
+ 			[neededSelectors add: m selector]].
- 	| sent out |
- 	sent := Set new.
- 	methods do: [ :m |
- 		m export ifTrue:[sent add: m selector].
- 		sent addAll: m allCalls.
- 	].
  
+ 	"Now compute the transitive closure..."
+ 	previousSize := neededSelectors size.
+ 	visited := IdentitySet new: methods size.
+ 	[neededSelectors do:
+ 		[:s|
+ 		(methods at: s ifAbsent: []) ifNotNil:
+ 			[:m|
+ 			(visited includes: m) ifFalse:
+ 				[visited add: m.
+ 				 m export ifTrue:
+ 					[neededSelectors
+ 						add: m selector;
+ 						addAll: m allCalls]]]].
+ 	 neededSelectors size > previousSize]
+ 		whileTrue:
+ 			[previousSize := neededSelectors size].
+ 
+ 	^methods reject: [:m| neededSelectors includes: m selector]!
- 	out := OrderedCollection new.
- 	methods keys do: [ :sel |
- 		(sent includes: sel) ifFalse: [ out add: sel ].
- 	].
- 	^ out!

Item was added:
+ ----- Method: InterpreterPlugin class>>pruneUnusedInterpreterPluginMethodsIn: (in category 'translation') -----
+ pruneUnusedInterpreterPluginMethodsIn: aCodeGen
+ 	aCodeGen unreachableMethods do:
+ 		[:m|
+ 		 m definingClass = InterpreterPlugin ifTrue:
+ 			[aCodeGen removeMethodForSelector: m selector]]!

Item was changed:
  ----- Method: InterpreterPlugin class>>translateInDirectory:doInlining: (in category 'translation') -----
  translateInDirectory: directory doInlining: inlineFlag
  "This is the default method for writing out sources for a plugin. Several classes need special handling, so look at all implementors of this message"
  	| cg fname fstat |
  	 fname := self moduleName, '.c'.
  
  	"don't translate if the file is newer than my timeStamp"
  	fstat := directory entryAt: fname ifAbsent:[nil].
  	fstat ifNotNil:
  		[((self pluginClassesUpTo: self) allSatisfy:
  				[:aPluginClass| aPluginClass timeStamp < fstat modificationTime]) ifTrue:
  			[^nil]].
  
  	self initialize.
  	cg := self buildCodeGeneratorUpTo: self.
  	cg inferTypesForImplicitlyTypedVariablesAndMethods.
+ 	self pruneUnusedInterpreterPluginMethodsIn: cg.
  	cg storeCodeOnFile:  (directory fullNameFor: fname) doInlining: inlineFlag.
  	^cg exportedPrimitiveNames asArray!

Item was removed:
- ----- Method: LargeIntegersPlugin class>>buildCodeGeneratorUpTo: (in category 'translation') -----
- buildCodeGeneratorUpTo: someClass 
- 	"A hook to control generation of the plugin. Don't know how to set the 
- 	debug mode otherwise if using the VMMaker gui. Possibly there is a better way."
- 	| cg |
- 	cg := super buildCodeGeneratorUpTo: someClass.
- 	"example: cg generateDebugCode: true."
- 	^ cg!

Item was changed:
  ----- Method: MiscPrimitivePlugin class>>translateInDirectory:doInlining: (in category 'translation') -----
  translateInDirectory: directory doInlining: inlineFlag
  "handle a special case code string rather than normal generated code."
  	| cg fname fstat |
  	 fname := self moduleName, '.c'.
  
  	"don't translate if the file is newer than my timeStamp"
  	fstat := directory entryAt: fname ifAbsent:[nil].
  	fstat ifNotNil:[self timeStamp < fstat modificationTime ifTrue:[^nil]].
  
  	self initialize.
  	cg := self buildCodeGeneratorUpTo: InterpreterPlugin.
  	cg addMethodsForPrimitives: self translatedPrimitives.
+ 	self pruneUnusedInterpreterPluginMethodsIn: cg.
  	self storeString: cg generateCodeStringForPrimitives onFileNamed: (directory fullNameFor: fname).
  	^cg exportedPrimitiveNames asArray
  !

Item was changed:
  ----- Method: SoundGenerationPlugin class>>translateInDirectory:doInlining: (in category 'accessing') -----
  translateInDirectory: directory doInlining: inlineFlag
  "handle a special case code string rather than generated code. 
  NB sqOldSoundsPrims IS NOT FULLY INTEGRATED - it still isn't included in the exports list"
  	| cg |
  	self initialize.
  
  	cg := self buildCodeGeneratorUpTo: InterpreterPlugin.
  
  	cg addMethodsForPrimitives: AbstractSound translatedPrimitives.
+ 	self pruneUnusedInterpreterPluginMethodsIn: cg.
  	self storeString: cg generateCodeStringForPrimitives onFileNamed: (directory fullNameFor: self moduleName, '.c').
  	"What we need here is some way to derive the prim names from sqOldSoundPrims - or dump it entirely. Perhaps add this class (without then generating the file again) using fake entry points like SurfacePlugin does"
  
  	^cg exportedPrimitiveNames asArray
  !



More information about the Vm-dev mailing list