The Trunk: Compiler-eem.341.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Compiler-eem.341.mcz

commits-2
Eliot Miranda uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-eem.341.mcz

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

Name: Compiler-eem.341
Author: eem
Time: 3 April 2017, 5:25:34.125602 pm
UUID: a66d7b39-0d0f-4d67-8e82-02964c101b10
Ancestors: Compiler-eem.340

Add the refactored encoder-specific method generator.  This one moves generation from MethodNode to BytecodeEncoder and subclasses, and hence allows easier bytecode set selection, or at least far more sends to self than to encoder.

=============== Diff against Compiler-eem.340 ===============

Item was added:
+ ----- Method: BytecodeEncoder>>generateMethodOfClass:trailer:from: (in category 'method encoding') -----
+ generateMethodOfClass: aCompiledMethodClass trailer: trailer from: methodNode
+ "The receiver is the root of a parse tree. Answer an instance of aCompiledMethodClass.
+ The argument, trailer, is arbitrary but is typically either the reference to the source code
+ that is stored with every CompiledMethod, or an encoding of the method's temporary names."
+
+ | primErrNode blkSize nLits locals literals header method stack |
+ primErrNode := methodNode primitiveErrorVariableName ifNotNil:
+ [self fixTemp: methodNode primitiveErrorVariableName].
+ methodNode ensureClosureAnalysisDone.
+ self rootNode: methodNode. "this is for BlockNode>>sizeCodeForClosureValue:"
+ blkSize := (methodNode block sizeCodeForEvaluatedValue: self)
+ + (methodNode primitive > 0
+ ifTrue: [self sizeCallPrimitive: methodNode primitive]
+ ifFalse: [0])
+ + (primErrNode
+ ifNil: [0]
+ ifNotNil:
+ [primErrNode
+ index: methodNode arguments size + methodNode temporaries size;
+ sizeCodeForStore: self "The VM relies on storeIntoTemp: (129)"]).
+ locals := methodNode arguments, methodNode temporaries, (primErrNode ifNil: [#()] ifNotNil: [{primErrNode}]).
+ self noteBlockExtent: methodNode block blockExtent hasLocals: locals.
+ header := self computeMethodHeaderForNumArgs: methodNode arguments size
+ numTemps: locals size
+ numLits: (nLits := (literals := self allLiterals) size)
+ primitive: methodNode primitive.
+ method := trailer
+ createMethod: blkSize
+ class: aCompiledMethodClass
+ header: header.
+ 1 to: nLits do: [:lit | method literalAt: lit put: (literals at: lit)].
+ self streamToMethod: method.
+ stack := ParseStack new init.
+ methodNode primitive > 0 ifTrue:
+ [self genCallPrimitive: methodNode primitive].
+ primErrNode ifNotNil:
+ [primErrNode emitCodeForStore: stack encoder: self].
+ stack position: method numTemps.
+ [methodNode block emitCodeForEvaluatedValue: 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 CompiledMethod class>>#new:"
+ ex signalerContext sender method = (CompiledMethod class>>#new:)
+ ifTrue: [^self error: 'Compiler code size discrepancy']
+ ifFalse: [ex pass]].
+ stack position ~= (method numTemps + 1) ifTrue:
+ [^self error: 'Compiler stack discrepancy'].
+ self methodStreamPosition ~= (method size - trailer size) ifTrue:
+ [^self error: 'Compiler code size discrepancy'].
+ method needsFrameSize: stack size - method numTemps.
+ ^method!