[squeak-dev] The Trunk: Compiler-eem.377.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Mar 14 22:38:27 UTC 2018

Eliot Miranda uploaded a new version of Compiler to project The Trunk:

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

Name: Compiler-eem.377
Author: eem
Time: 14 March 2018, 3:38:12.426121 pm
UUID: e69687e2-f183-40f0-abed-f080749ea44e
Ancestors: Compiler-eem.376

Fix compiler bug with full blocks.  Old code added an extra literal nil.

=============== Diff against Compiler-eem.376 ===============

Item was added:
+ ----- Method: BytecodeEncoder>>allLiteralsForBlockMethod (in category 'results') -----
+ allLiteralsForBlockMethod
+ 	"N.B. addedSelectorAndMethodClassLiterals is a misnomer.  It should be something like
+ 	 addedImplicitLiterals or addedExtraLiterals."
+ 	addedSelectorAndMethodClassLiterals ifFalse:
+ 		[addedSelectorAndMethodClassLiterals := true.
+ 		"Put the optimized selectors in literals so as to browse senders more easily"
+ 		optimizedSelectors := optimizedSelectors reject: [:e| literalStream originalContents hasLiteral: e].
+ 		optimizedSelectors isEmpty ifFalse: [
+ 			"Use one entry per literal if enough room, else make anArray"
+ 			literalStream position + optimizedSelectors size + 2 >= self maxNumLiterals
+ 				ifTrue: [self litIndex: optimizedSelectors asArray]
+ 				ifFalse: [optimizedSelectors do: [:e | self litIndex: e]]].
+ 		"Add a slot for outerCode"
+ 		self litIndex: nil].
+ 	^literalStream contents!

Item was changed:
  ----- Method: BytecodeEncoder>>generateBlockMethodOfClass:trailer:from: (in category 'method encoding') -----
  generateBlockMethodOfClass: aCompiledBlockClass trailer: trailer from: blockNode
  	"Generate a CompiledBlock for the block whose parse tree is blockNode."
  	"The closure analysis should already have been done."
  	| blkSize header literals locals method nLits stack |
  	self assert: blockNode blockExtent notNil.
  	self assert: rootNode notNil.
  	blkSize := blockNode sizeCodeForEvaluatedFullClosureValue: self.
  	locals := blockNode localsNodes.
  	self noteBlockExtent: blockNode blockExtent hasLocals: locals.
  	header := self computeMethodHeaderForNumArgs: blockNode arguments size
  					numTemps: locals size
+ 					numLits: (nLits := (literals := self allLiteralsForBlockMethod) size)
- 					numLits: (nLits := (literals := self allLiterals) size)
  					primitive: 0.
  	method := trailer
  					createMethod: blkSize
  					class: aCompiledBlockClass
  					header: header.
  	1 to: nLits do:
  		[:lit |
  		(method literalAt: lit put: (literals at: lit)) isCompiledCode ifTrue:
  			[(literals at: lit) outerCode: method]].
  	self streamToMethod: method.
  	stack := ParseStack new init.
  	stack position: method numTemps.
  	blockMethod := method. "For BytecodeEncoder>>pc & BytecodeEncoder>>nextPC"
  	[blockNode emitCodeForEvaluatedFullClosureValue: stack encoder: self]
  		on: Error "If an attempt is made to write too much code the method will be asked"
  		do: [:ex|  "to grow, and the grow attempt will fail in CompiledCode class>>#newMethodViaNewError"
  			ex signalerContext sender method = (CompiledCode class>>#newMethodViaNewError)
  				ifTrue: [^self error: 'Compiler code size discrepancy']
  				ifFalse: [ex pass]].
  	stack position ~= (method numTemps + 1) ifTrue:
  		[^self error: 'Compiler stack discrepancy'].
  	stream position ~= (method size - trailer size) ifTrue:
  		[^self error: 'Compiler code size discrepancy'].
  	method needsFrameSize: stack size - method numTemps.

More information about the Squeak-dev mailing list