The Trunk: Compiler-eem.309.mcz

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

The Trunk: Compiler-eem.309.mcz

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

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

Name: Compiler-eem.309
Author: eem
Time: 16 September 2015, 5:26:18.544 pm
UUID: 89f65602-802e-41c5-b52c-c85cf61e299f
Ancestors: Compiler-eem.308

Fix the compiler to collapse optimized block temps of the same name to the same temp location for a better debugging UX.

=============== Diff against Compiler-eem.308 ===============

Item was changed:
  ----- Method: BlockNode>>addHoistedTemps: (in category 'code generation (closures)') -----
  addHoistedTemps: additionalTemporaries "<SequenceableCollection>"
+ | tempsToBeMerged additionalTempsToAdd |
  additionalTemporaries do:
  [:temp|
  temp definingScope ifNil:
  [temp definingScope: self]].
+ (temporaries isNil or: [temporaries isEmpty]) ifTrue:
+ [temporaries := additionalTemporaries copy.
+ ^self].
+ tempsToBeMerged := additionalTemporaries select:
+ [:t|
+ t isBlockArg
+ and: [temporaries anySatisfy: [:existing| existing isBlockArg and: [existing key = t key]]]].
+ additionalTempsToAdd := tempsToBeMerged isEmpty
+ ifTrue: [additionalTemporaries copy]
+ ifFalse: [additionalTemporaries reject: [:temp| tempsToBeMerged identityIncludes: temp]].
  temporaries := (temporaries isNil or: [temporaries isEmpty])
+ ifTrue: [additionalTempsToAdd]
- ifTrue: [additionalTemporaries copy]
  ifFalse:
  [temporaries last isIndirectTempVector
+ ifTrue: [temporaries allButLast, additionalTempsToAdd, { temporaries last }]
+ ifFalse: [temporaries, additionalTempsToAdd]].
+ tempsToBeMerged do:
+ [:t| | merge |
+ merge := temporaries detect: [:existing| existing isBlockArg and: [existing key = t key]].
+ merge absorbHoistedTemp: t]!
- ifTrue: [temporaries allButLast, additionalTemporaries, { temporaries last }]
- ifFalse: [temporaries, additionalTemporaries]]!

Item was changed:
  ----- Method: BytecodeEncoder>>bindTemp: (in category 'temps') -----
  bindTemp: name
  "Declare a temporary; error not if a field or class variable or out-of-scope temp.
  Read the comment in Encoder>>bindBlockArg:within: and subclass implementations."
  self supportsClosureOpcodes ifFalse:
  [^super bindTemp: name].
  scopeTable at: name ifPresent:
  [:node|
  "When non-interactive raise the error only if it is a duplicate"
  node isTemp
  ifTrue:[node scope >= 0 ifTrue:
+ [^self notify: 'Name already used in this method']]
- [^self notify:'Name is already defined']]
  ifFalse:[self warnAboutShadowed: name]].
  ^self reallyBind: name!

Item was added:
+ ----- Method: TempVariableNode>>absorbHoistedTemp: (in category 'code generation (closures)') -----
+ absorbHoistedTemp: aTempVar
+ "Collapse aTempVar into the receiver, being sure to update any closure analysis."
+ aTempVar copyScopeAccessTo: self.
+ aTempVar becomeForward: self!

Item was added:
+ ----- Method: TempVariableNode>>copyScopeAccessTo: (in category 'code generation (closures)') -----
+ copyScopeAccessTo: aTempVar
+ "For absorbHoistedTemp:, copy the receiver's reads and writes into the record in aTempVar."
+ readingScopes ifNotNil:
+ [readingScopes keysAndValuesDo:
+ [:scopeBlock :reads|
+ reads do:
+ [:location|
+ aTempVar addReadWithin: scopeBlock "<BlockNode>" at: location]]].
+ writingScopes ifNotNil:
+ [writingScopes keysAndValuesDo:
+ [:scopeBlock :writes|
+ writes do:
+ [:location|
+ aTempVar addWriteWithin: scopeBlock "<BlockNode>" at: location]]]!

Item was changed:
+ (PackageInfo named: 'Compiler') postscript: '"Make sure all affected methods are recompiled"
+ UIManager default
+ informUser: ''Recompiling affected methods''
+ during:
+ [(self systemNavigation allMethodsSelect:
+ [:m| | ebc | "All affected methods send one of these optimized selectors..."
+ (#(to:do: to:by:do: ifNotNil: ifNil:ifNotNil: ifNotNil:ifNil:) anySatisfy: [:l| m refersToLiteral: l])
+ "but the textDomain properties confuse method comparison below..."
+ and: [(m propertyValueAt: #textDomain ifAbsent: nil) isNil
+ and: [m numTemps > m numArgs "and have non-argument temporaries in them..."
+  or: [(ebc := m embeddedBlockClosures) notEmpty
+ and: [ebc anySatisfy: [:bc| bc numTemps > bc numArgs]]]]]]) do:
+ [:mr| | old new |
+ old := mr compiledMethod.
+ "do a test recompile of the method..."
+ new := (mr actualClass compile: old getSource asString notifying: nil trailer: old trailer ifFail: nil) method.
+ "and if it changed, report it to the transcript and really recompile it..."
+ old ~= new ifTrue:
+ [Transcript cr. old printReferenceOn: Transcript. Transcript flush.
+ mr actualClass recompile: old selector]]]'!
- (PackageInfo named: 'Compiler') postscript: '"Migrate preference value"
- Scanner allowBlockArgumentAssignment: Preferences allowBlockArgumentAssignment'!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Compiler-eem.309.mcz

Levente Uzonyi-2
Thanks Eliot! Those duplicated variable names were quite annoying.

Levente

On Thu, 17 Sep 2015, [hidden email] wrote:

> Eliot Miranda uploaded a new version of Compiler to project The Trunk:
> http://source.squeak.org/trunk/Compiler-eem.309.mcz
>
> ==================== Summary ====================
>
> Name: Compiler-eem.309
> Author: eem
> Time: 16 September 2015, 5:26:18.544 pm
> UUID: 89f65602-802e-41c5-b52c-c85cf61e299f
> Ancestors: Compiler-eem.308
>
> Fix the compiler to collapse optimized block temps of the same name to the same temp location for a better debugging UX.
>
> =============== Diff against Compiler-eem.308 ===============
>
> Item was changed:
>  ----- Method: BlockNode>>addHoistedTemps: (in category 'code generation (closures)') -----
>  addHoistedTemps: additionalTemporaries "<SequenceableCollection>"
> + | tempsToBeMerged additionalTempsToAdd |
>   additionalTemporaries do:
>   [:temp|
>   temp definingScope ifNil:
>   [temp definingScope: self]].
> + (temporaries isNil or: [temporaries isEmpty]) ifTrue:
> + [temporaries := additionalTemporaries copy.
> + ^self].
> + tempsToBeMerged := additionalTemporaries select:
> + [:t|
> + t isBlockArg
> + and: [temporaries anySatisfy: [:existing| existing isBlockArg and: [existing key = t key]]]].
> + additionalTempsToAdd := tempsToBeMerged isEmpty
> + ifTrue: [additionalTemporaries copy]
> + ifFalse: [additionalTemporaries reject: [:temp| tempsToBeMerged identityIncludes: temp]].
>   temporaries := (temporaries isNil or: [temporaries isEmpty])
> + ifTrue: [additionalTempsToAdd]
> - ifTrue: [additionalTemporaries copy]
>   ifFalse:
>   [temporaries last isIndirectTempVector
> + ifTrue: [temporaries allButLast, additionalTempsToAdd, { temporaries last }]
> + ifFalse: [temporaries, additionalTempsToAdd]].
> + tempsToBeMerged do:
> + [:t| | merge |
> + merge := temporaries detect: [:existing| existing isBlockArg and: [existing key = t key]].
> + merge absorbHoistedTemp: t]!
> - ifTrue: [temporaries allButLast, additionalTemporaries, { temporaries last }]
> - ifFalse: [temporaries, additionalTemporaries]]!
>
> Item was changed:
>  ----- Method: BytecodeEncoder>>bindTemp: (in category 'temps') -----
>  bindTemp: name
>   "Declare a temporary; error not if a field or class variable or out-of-scope temp.
>   Read the comment in Encoder>>bindBlockArg:within: and subclass implementations."
>   self supportsClosureOpcodes ifFalse:
>   [^super bindTemp: name].
>   scopeTable at: name ifPresent:
>   [:node|
>   "When non-interactive raise the error only if it is a duplicate"
>   node isTemp
>   ifTrue:[node scope >= 0 ifTrue:
> + [^self notify: 'Name already used in this method']]
> - [^self notify:'Name is already defined']]
>   ifFalse:[self warnAboutShadowed: name]].
>   ^self reallyBind: name!
>
> Item was added:
> + ----- Method: TempVariableNode>>absorbHoistedTemp: (in category 'code generation (closures)') -----
> + absorbHoistedTemp: aTempVar
> + "Collapse aTempVar into the receiver, being sure to update any closure analysis."
> + aTempVar copyScopeAccessTo: self.
> + aTempVar becomeForward: self!
>
> Item was added:
> + ----- Method: TempVariableNode>>copyScopeAccessTo: (in category 'code generation (closures)') -----
> + copyScopeAccessTo: aTempVar
> + "For absorbHoistedTemp:, copy the receiver's reads and writes into the record in aTempVar."
> + readingScopes ifNotNil:
> + [readingScopes keysAndValuesDo:
> + [:scopeBlock :reads|
> + reads do:
> + [:location|
> + aTempVar addReadWithin: scopeBlock "<BlockNode>" at: location]]].
> + writingScopes ifNotNil:
> + [writingScopes keysAndValuesDo:
> + [:scopeBlock :writes|
> + writes do:
> + [:location|
> + aTempVar addWriteWithin: scopeBlock "<BlockNode>" at: location]]]!
>
> Item was changed:
> + (PackageInfo named: 'Compiler') postscript: '"Make sure all affected methods are recompiled"
> + UIManager default
> + informUser: ''Recompiling affected methods''
> + during:
> + [(self systemNavigation allMethodsSelect:
> + [:m| | ebc | "All affected methods send one of these optimized selectors..."
> + (#(to:do: to:by:do: ifNotNil: ifNil:ifNotNil: ifNotNil:ifNil:) anySatisfy: [:l| m refersToLiteral: l])
> + "but the textDomain properties confuse method comparison below..."
> + and: [(m propertyValueAt: #textDomain ifAbsent: nil) isNil
> + and: [m numTemps > m numArgs "and have non-argument temporaries in them..."
> +  or: [(ebc := m embeddedBlockClosures) notEmpty
> + and: [ebc anySatisfy: [:bc| bc numTemps > bc numArgs]]]]]]) do:
> + [:mr| | old new |
> + old := mr compiledMethod.
> + "do a test recompile of the method..."
> + new := (mr actualClass compile: old getSource asString notifying: nil trailer: old trailer ifFail: nil) method.
> + "and if it changed, report it to the transcript and really recompile it..."
> + old ~= new ifTrue:
> + [Transcript cr. old printReferenceOn: Transcript. Transcript flush.
> + mr actualClass recompile: old selector]]]'!
> - (PackageInfo named: 'Compiler') postscript: '"Migrate preference value"
> - Scanner allowBlockArgumentAssignment: Preferences allowBlockArgumentAssignment'!
>
>
>