The Trunk: Compiler-eem.370.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.370.mcz

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

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

Name: Compiler-eem.370
Author: eem
Time: 11 January 2018, 8:41:19.10862 am
UUID: 277f856e-2abf-452c-a5e0-84d00819a04d
Ancestors: Compiler-eem.369

Move CompiledMethod>>startpcsToBlockExtents and its support machinery to Compiler; it is used both by the Decompiler and the Debugger and so belongs in Compiler, not in Tools.

=============== Diff against Compiler-eem.369 ===============

Item was changed:
  InstructionClient subclass: #BlockLocalTempCounter
  instanceVariableNames: 'stackPointer scanner blockEnd joinOffsets'
  classVariableNames: ''
  poolDictionaries: ''
  category: 'Compiler-Support'!
+ !BlockLocalTempCounter commentStamp: 'eem 1/11/2018 08:30' prior: 0!
+ I am a support class for the decompiler that is used to find the number of local temps in a block by finding out what the stack offset is at the end of a block.  I am necessary because in the EncoderForV3PlusClosures bytecode set the only way to initialize block-local temporaries is with pushConstant: nil bytecodes, but such bytecodes are ambiguous with a pushConstant: nil used to pass nil as a parameter or answer it as a result.  By scanning through to the end of the block these can be disambiguated by tracking the stack depth.!
- !BlockLocalTempCounter commentStamp: '<historical>' prior: 0!
- I am a support class for the decompiler that is used to find the number of local temps in a block by finding out what the stack offset is at the end of a block.!

Item was added:
+ InstructionClient subclass: #BlockStartLocator
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Compiler-Support'!
+ !BlockStartLocator commentStamp: 'eem 1/11/2018 08:32' prior: 0!
+ A BlockStartLocator is a scanner that locates the block creation bytecodes in a method.  For block creation bytecodes it answers information salient to the kind of block being created, and for all other bytecodes simply answers itself.
+ Instance Variables
+ !

Item was added:
+ ----- Method: BlockStartLocator>>pushClosureCopyNumCopiedValues:numArgs:blockSize: (in category 'instruction decoding') -----
+ pushClosureCopyNumCopiedValues: numCopied numArgs: numArgs blockSize: blockSize
+ "Answer the size of the block"
+ ^blockSize!

Item was added:
+ ----- Method: BlockStartLocator>>pushFullClosure:numCopied: (in category 'instruction decoding') -----
+ pushFullClosure: aCompiledBlock numCopied: numCopied
+ "Answer the block method"
+ ^aCompiledBlock!

Item was added:
+ ----- Method: CompiledMethod>>blockExtentsInto:from:to:scanner:numberer: (in category '*Compiler-support') -----
+ blockExtentsInto: aDictionary from: initialPC to: endPC scanner: scanner numberer: numbererBlock
+ "Support routine for startpcsToBlockExtents"
+ | extentStart blockSizeOrLocator |
+ extentStart := numbererBlock value.
+ [scanner pc <= endPC] whileTrue:
+ [blockSizeOrLocator := scanner interpretNextInstructionFor: BlockStartLocator new.
+ blockSizeOrLocator isInteger ifTrue:
+ [self
+ blockExtentsInto: aDictionary
+ from: scanner pc
+ to: scanner pc + blockSizeOrLocator - 1
+ scanner: scanner
+ numberer: numbererBlock]].
+ aDictionary at: initialPC put: (extentStart to: numbererBlock value).
+ ^aDictionary!

Item was added:
+ ----- Method: CompiledMethod>>startpcsToBlockExtents (in category '*Compiler-support') -----
+ startpcsToBlockExtents
+ "Answer a Dictionary of startpc to Interval of blockExtent, using the
+ identical numbering scheme described in and orchestrated by
+ BlockNode>>analyseArguments:temporaries:rootNode:.  This is used
+ to find the temp names for any block in a method, as needed by the
+ decompiler and debugger.  By indirecting through the blockExtent
+ instead of using the startpc directly we decouple access to temp
+ names from the exact bytecode; insulating the decompiler and
+ debugger from minor changes in the compiler's output.  If the
+ recompilation doesn't produce exactly the same bytecode at exactly
+ the same offset no matter; the blockExtents will be the same."
+ | index |
+ index := 0.
+ ^self
+ blockExtentsInto: Dictionary new
+ from: self initialPC
+ to: self endPC
+ scanner: (InstructionStream on: self)
+ numberer: [| value | value := index. index := index + 2. value]!