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

commits at source.squeak.org commits at source.squeak.org
Fri Dec 8 18:56:56 UTC 2017

Eliot Miranda uploaded a new version of VMMaker to project VM Maker:

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

Name: VMMaker.oscog-eem.2290
Author: eem
Time: 8 December 2017, 10:56:23.758751 am
UUID: db77672d-ac4b-4a9e-9e62-49d34e07678c
Ancestors: VMMaker.oscog-eem.2289

Include short int as a valid integral type.

Eliminate noisy unnecessary casts of constant integers to various unsigned types on inlining.

Eliminate noisy carriage returns between comment and leaf in translations of commented leaf nodes in expressions.

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

Item was changed:
  ----- Method: CCodeGenerator>>isIntegralCType: (in category 'inlining') -----
  isIntegralCType: aCType "<String>"
  	^(#('sqLong' 'usqLong' 'sqInt' 'usqInt' 'sqIntptr_t' 'usqIntptr_t'
+ 		'long' 'long long' 'int' 'short' 'short int' 'char' 'signed char'
- 		'long' 'int' 'short' 'char' 'signed char'
  		'size_t' 'pid_t') includes: aCType asString)
  	or: [(aCType beginsWith: 'unsigned') "Accept e.g. 'unsigned long' and also 'unsigned  : 8'"
  		and: [(aCType includesAnyOf: '[*]') not]]!

Item was added:
+ ----- Method: CCodeGenerator>>isNode:constantValueWithinRangeOfType: (in category 'type inference') -----
+ isNode: aNode constantValueWithinRangeOfType: aType
+ 	"Answer if aNode is a constant value within the range of an integral type.
+ 	 If aNode isn't an integral constant or aType isn't an integral type then answer false."
+ 	| value |
+ 	^aNode expression isConstant
+ 	  and: [(self isIntegralCType: aType)
+ 	  and: [(value := aNode expression value) isInteger
+ 	  and: [value positive
+ 	  and: [(aType first = $u
+ 			ifTrue: [value digitLength]
+ 			ifFalse: [value highBit + 7 // 8]) <= (self sizeOfIntegralCType: aType)]]]]!

Item was changed:
  ----- Method: TMethod>>propagateReturnIn: (in category 'inlining support') -----
  propagateReturnIn: aCodeGen
  	"Propagate the return type to all return nodes"
  	| map coercionType |
  	returnType = #void ifTrue:
  	"The following is necessary for functions returning functions, which have problematic syntax"
  	coercionType := aCodeGen
  							extractTypeFor: (aCodeGen cFunctionNameFor: self selector)
  							fromDeclaration: returnType.
  	map := IdentityDictionary new.
  	parseTree nodesDo:[:node|
  		(node isReturn
+ 		 and: [(aCodeGen typeFor: node expression in: self) ~= coercionType
+ 		 and: [(aCodeGen isNode: node constantValueWithinRangeOfType: coercionType) not]]) ifTrue:
+ 			[map at: node expression put: (aCodeGen nodeToCast: node expression to: coercionType)]].
- 		 and: [(aCodeGen typeFor: node expression in: self) ~= coercionType]) ifTrue:
- 			[map at: node expression put: (TSendNode new
- 				setSelector: #cCoerce:to:
- 				receiver: (TVariableNode new setName: 'self')
- 				arguments: {node expression.
- 							TConstantNode new setValue: coercionType})]].
  	self replaceNodesIn: map!

Item was changed:
  ----- Method: TStmtListNode>>emitCCodeAsArgumentOn:level:generator: (in category 'C code generation') -----
  emitCCodeAsArgumentOn: aStream level: level generator: aCodeGen
  	| size |
  	(size := statements size) = 1 ifTrue:
  		[^statements first emitCCodeAsArgumentOn: aStream level: level generator: aCodeGen].
+ 	"Get rid of the annoying newlines in ? : if-then-elses"
+ 	(size = 2 and: [statements first isComment and: [statements last isLeaf]]) ifTrue:
+ 		[statements first emitCCodeAsArgumentOn: aStream level: 0 generator: aCodeGen.
+ 		 aStream space.
+ 		 ^statements last emitCCodeAsArgumentOn: aStream level: 0 generator: aCodeGen].
  	aStream nextPut: $(. "N.B.  Comma binds weakest of all C operators."
  	statements withIndexDo:
  		[:s :idx| | p1 p2 |
  		p1 := aStream position.
  		s emitCCommentOn: aStream level: level generator: aCodeGen.
  		(s isLeaf and: [s isLabel not and: [idx < statements size]]) ifFalse:
  			[s emitCCodeAsArgumentOn: aStream level: level + 1 generator: aCodeGen].
  		p2 := aStream position.
  		(idx < size and: [p2 > p1]) ifTrue:
  			[((self endsWithCloseBracket: aStream)
  			  or: [s isComment]) ifFalse: [aStream nextPut: $,].
  			 aStream crtab: level]].
  	aStream nextPut: $)!

More information about the Vm-dev mailing list