[ENH][VM] Improved code generation (hopefully ;)

John M McIntosh johnmci at mac.com
Tue Jul 8 00:44:42 UTC 2003


> ou might be using some changes which undo some of those that I did.  
> The CS
> certainly contains the changes, e.g.,
>
> CCodeGenerator>>doInlining: inlineFlag
> "..."
> self inlineDispatchesInMethodNamed: #interpret
> localizingVars: #(currentBytecode localIP localSP
> localHomeContext localReturnContext localReturnValue).
>
> Check the senders of #inlineDispatchesInMethodNamed:localizingVars:  
> and see
> if that list includes localReturnContext and localReturnValue. If not,  
> then
> something's wrong.
>


No all I did was download Squeak3.6a-5325 and update from server, then  
update squeakmap, then install
VMMaker, then install your two changesets.

I've this below, which is the only sender of of  
#inlineDispatchesInMethodNamed:localizingVars: .

doInlining: inlineFlag
	"Inline the bodies of all methods that are suitable for inlining."
	"Modified slightly for the translator, since the first level of  
inlining for the interpret loop must be performed in order that the  
instruction implementations can easily discover their addresses."

	| pass progress |
	inlineFlag ifFalse: [
		self inlineDispatchesInMethodNamed: #interpret localizingVars: #().
		^ self].

	self collectInlineList.
	pass _ 0.
	progress _ true.
	[progress] whileTrue: [
		"repeatedly attempt to inline methods until no further progress is  
made"
		progress _ false.
		('Inlining pass ', (pass _ pass + 1) printString, '...')
			displayProgressAt: Sensor cursorPoint
			from: 0 to: methods size
			during: [:bar |
				methods doWithIndex: [:m :i |
					bar value: i.
					(m tryToInlineMethodsIn: self)
						ifTrue: [progress _ true]]]].

	'Inlining bytecodes'
		displayProgressAt: Sensor cursorPoint
		from: 1 to: 2
		during: [:bar |
			self inlineDispatchesInMethodNamed: #interpret
				localizingVars: #(currentBytecode localIP localSP localHomeContext  
localReturnContext localReturnValue).
			bar value: 1.
			self removeMethodsReferingToGlobals: #(
					currentBytecode localIP localSP localHomeContext)
				except: #interpret.
			bar value: 2].

	"make receiver on the next line false to generate code for all  
methods, even those that are inlined or unused"
	true ifTrue: [
		(methods includesKey: #interpret) ifTrue: [
			"only prune when generating the interpreter itself"
			self pruneUnreachableMethods]].


Which gives

int interpret(void) {
register struct foo * foo = &fum;
     int localHomeContext;
     char* localSP;
     char* localIP;
     int currentBytecode;

	/* begin internalizeIPandSP */
	localIP = ((char *) foo->instructionPointer);
	localSP = ((char *) foo->stackPointer);
	localHomeContext = foo->theHomeContext;
	/* begin fetchNextBytecode */
	currentBytecode = byteAt(++localIP);
	while (1) {




--
======================================================================== 
===
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
======================================================================== 
===



More information about the Squeak-dev mailing list