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

commits at source.squeak.org commits at source.squeak.org
Sat Sep 19 16:13:41 UTC 2020


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

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

Name: VMMaker.oscog-eem.2811
Author: eem
Time: 19 September 2020, 9:13:31.325566 am
UUID: fa96b358-e3c8-4591-8595-20003329c559
Ancestors: VMMaker.oscog-eem.2810

Slang: tweak translatedPrimitive generation so that
- SmallInteger maxVal is translated correctly to MaxSmallInteger (etc)
- methodReturnRecever and methodReturnInteger are used in preference to pop: and pop:;pushInteger:.

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

Item was changed:
  ----- Method: TMethod>>fixUpReturns:postlog: (in category 'primitive compilation') -----
  fixUpReturns: argCount postlog: postlog
  	"Replace each return statement in this method with (a) the given postlog, (b) code to pop the receiver and the given number of arguments, and (c) code to push the integer result and return."
  
+ 	parseTree nodesDo:
+ 		[:node | | newStmts |
+ 		node isStmtList ifTrue:
+ 			[newStmts := OrderedCollection new: node statements size + 10.
+ 			node statements do:
+ 				[:stmt |
+ 				 stmt isReturn
+ 					ifTrue:
+ 						[(stmt expression isSend and: [#primitiveFail = stmt expression selector])
+ 							ifTrue:  "failure return"
+ 								[newStmts
+ 									addLast: stmt expression;
+ 									addLast: (TReturnNode new setExpression:
+ 												(TVariableNode new setName: 'null'))]
+ 							ifFalse:  "normal return"
+ 								[newStmts
+ 									addAll: postlog;
+ 									addLast: (TReturnNode new setExpression:
+ 												((stmt expression isVariable and: [#('nil' 'null' 'self') includes: stmt expression name])
+ 													ifTrue:
+ 														[TSendNode new
+ 															setSelector: #methodReturnReceiver
+ 															receiver: (TVariableNode new setName: self vmNameString)
+ 															arguments: #()]
+ 													ifFalse:
+ 														[TSendNode new
+ 															setSelector: #methodReturnInteger:
+ 															receiver: (TVariableNode new setName: self vmNameString)
+ 															arguments: {stmt expression}]))]]
+ 					ifFalse:
+ 						[newStmts addLast: stmt]].
+ 			node setStatements: newStmts asArray]]!
- 	| newStmts |
- 	parseTree nodesDo: [:node |
- 		node isStmtList ifTrue: [
- 			newStmts := OrderedCollection new: 100.
- 			node statements do: [:stmt |
- 				stmt isReturn
- 					ifTrue: [
- 						(stmt expression isSend and:
- 						 ['primitiveFail' = stmt expression selector])
- 							ifTrue: [  "failure return"
- 								newStmts addLast: stmt expression.
- 								newStmts addLast: (TReturnNode new
- 									setExpression: (TVariableNode new setName: 'null'))]
- 							ifFalse: [  "normal return"
- 								newStmts addAll: postlog.
- 								newStmts addAll: (self popArgsExpr: argCount + 1).
- 								newStmts addLast: (TSendNode new
- 									setSelector: #pushInteger:
- 									receiver: (TVariableNode new setName: self vmNameString)
- 									arguments: (Array with: stmt expression)).
- 								newStmts addLast: (TReturnNode new
- 									setExpression: (TVariableNode new setName: 'null'))]]
- 					ifFalse: [
- 						newStmts addLast: stmt]].
- 			node setStatements: newStmts asArray]].
- !

Item was changed:
  ----- Method: TMethod>>mapSendsFromSelfToInterpreterProxy: (in category 'transformations') -----
  mapSendsFromSelfToInterpreterProxy: selectors
+ 	| interpreterProxyNode replacements |
- 	| interpreterProxyNode |
  	interpreterProxyNode := TVariableNode new setName: 'interpreterProxy'.
+ 	replacements := Dictionary new.
  	parseTree nodesDo:
  		[:node|
  		(node isSend
+ 		 and: [node receiver isVariable
+ 		 and: [selectors includes: node selector]]) ifTrue:
+ 			[node receiver name = 'self' ifTrue:
+ 				[node receiver: interpreterProxyNode].
+ 			 node receiver name = 'SmallInteger' ifTrue:
+ 				[replacements
+ 					at: node
+ 					put: (TVariableNode new setName:
+ 							(node selector = #maxVal
+ 									ifTrue: ['MaxSmallInteger']
+ 									ifFalse: ['MinSmallInteger']))]]].
+ 	replacements notEmpty ifTrue:
+ 		[parseTree replaceNodesIn: replacements]!
- 		and: [node receiver isVariable
- 		and: [node receiver name = 'self'
- 		and: [selectors includes: node selector]]]) ifTrue:
- 			[node receiver: interpreterProxyNode]]!

Item was changed:
  ----- Method: TMethod>>popArgsExpr: (in category 'primitive compilation') -----
  popArgsExpr: argCount
+ 	"Answer the parse tree for an expression that pops the given number of arguments from the stack."
- 	"Return the parse tree for an expression that pops the given number of arguments from the stack."
  
+ 	^self statementsFor: '^', self vmNameString, ' ', #methodReturnReceiver varName: ''!
- 	| expr |
- 	expr := '', self vmNameString, ' pop: ', argCount printString.
- 	^ self statementsFor: expr varName: ''
- !

Item was changed:
  ----- Method: VMPluginCodeGenerator>>prepareTranslatedPrimitives (in category 'C code generator') -----
  prepareTranslatedPrimitives
  	"Translated primitives need their prolog and epilog adding and all
  	 sends to self that should be sends to interpreterproxy changing."
  	methods do:
  		[:meth|
  		 meth primitive > 0 ifTrue:
  			[meth
  				preparePrimitivePrologue;
+ 				mapSendsFromSelfToInterpreterProxy: InterpreterProxy selectors, #(maxVal minVal)]]!
- 				mapSendsFromSelfToInterpreterProxy: InterpreterProxy selectors]]!



More information about the Vm-dev mailing list