The Inbox: Compiler-fm.287.mcz

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

The Inbox: Compiler-fm.287.mcz

commits-2
A new version of Compiler was added to project The Inbox:
http://source.squeak.org/inbox/Compiler-fm.287.mcz

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

Name: Compiler-fm.287
Author: fm
Time: 9 August 2014, 1:57:32.957 am
UUID: b7426a7e-9098-8b42-aa28-093253343ff4
Ancestors: Compiler-eem.286

avoid conflicts between temp names and instvar names (mostly valuable when decompiling without temp names),
also do not create remote temp names starting with underscore, this is unsupported

=============== Diff against Compiler-eem.286 ===============

Item was changed:
  ----- Method: Decompiler>>doClosureCopyCopiedValues:numArgs:blockSize: (in category 'control') -----
  doClosureCopyCopiedValues: blockCopiedValues numArgs: numArgs blockSize: blockSize
  | startpc savedTemps savedTempVarCount savedNumLocalTemps
   jump blockArgs blockTemps blockTempsOffset block |
  savedTemps := tempVars.
  savedTempVarCount := tempVarCount.
  savedNumLocalTemps := numLocalTemps.
  jump := blockSize + (startpc := pc).
+ numLocalTemps := BlockLocalTempCounter tempCountForBlockStartingAt: pc in: method.
- numLocalTemps := BlockLocalTempCounter
- tempCountForBlockStartingAt: pc
- in: method.
  blockTempsOffset := numArgs + blockCopiedValues size.
  (blockStartsToTempVars notNil "implies we were intialized with temp names."
  and: [blockStartsToTempVars includesKey: pc])
  ifTrue:
  [tempVars := blockStartsToTempVars at: pc]
  ifFalse:
  [blockArgs := (1 to: numArgs) collect:
+ [:i|  | uniqueName |
+ uniqueName := 't', (tempVarCount + i) printString.
+ [constructor instVars includes: uniqueName] whileTrue: [uniqueName := 't', uniqueName].
+ (constructor
+ codeTemp: i - 1
+ named: uniqueName)
+  beBlockArg].
- [:i| (constructor
- codeTemp: i - 1
- named: 't', (tempVarCount + i) printString)
-  beBlockArg].
  blockTemps := (1 to: numLocalTemps) collect:
+ [:i| | uniqueName |
+ uniqueName := 't', (tempVarCount + i + numArgs) printString.
+ [constructor instVars includes: uniqueName] whileTrue: [uniqueName := 't', uniqueName].
+ constructor
- [:i| constructor
  codeTemp: i + blockTempsOffset - 1
+ named: uniqueName].
- named: 't', (tempVarCount + i + numArgs) printString].
  tempVars := blockArgs, blockCopiedValues, blockTemps].
  numLocalTemps timesRepeat:
  [self interpretNextInstructionFor: self.
  stack removeLast].
  tempVarCount := tempVarCount + numArgs + numLocalTemps.
  block := self blockTo: jump.
  stack addLast: ((constructor
  codeArguments: (tempVars copyFrom: 1 to: numArgs)
  temps: (tempVars copyFrom: blockTempsOffset + 1 to: blockTempsOffset + numLocalTemps)
  block: block)
  pc: startpc;
  yourself).
  tempVars := savedTemps.
  tempVarCount := savedTempVarCount.
  numLocalTemps := savedNumLocalTemps!

Item was changed:
  ----- Method: Decompiler>>initSymbols: (in category 'initialize-release') -----
  initSymbols: aClass
  constructor method: method class: aClass literals: method literals.
  constTable := constructor codeConstants.
  instVars := Array new: aClass instSize.
  tempVarCount := method numTemps.
  "(tempVars isNil
  and: [method holdsTempNames]) ifTrue:
  [tempVars := method tempNamesString]."
  tempVars isString
  ifTrue:
  [blockStartsToTempVars := self mapFromBlockStartsIn: method
  toTempVarsFrom: tempVars
  constructor: constructor.
  tempVars := blockStartsToTempVars at: method initialPC]
  ifFalse:
  [| namedTemps |
+ namedTemps := tempVars ifNil: [(1 to: tempVarCount) collect: [:i| | uniqueName |
+ uniqueName := 't', i printString.
+ [constructor instVars includes: uniqueName] whileTrue: [uniqueName := 't', uniqueName].
+ uniqueName]].
- namedTemps := tempVars ifNil: [(1 to: tempVarCount) collect: [:i| 't', i printString]].
  tempVars := (1 to: tempVarCount) collect:
  [:i | i <= namedTemps size
  ifTrue: [constructor codeTemp: i - 1 named: (namedTemps at: i)]
  ifFalse: [constructor codeTemp: i - 1]]].
  1 to: method numArgs do:
  [:i|
  (tempVars at: i) beMethodArg]!

Item was changed:
  ----- Method: Decompiler>>popIntoTemporaryVariable: (in category 'instruction decoding') -----
  popIntoTemporaryVariable: offset
  | maybeTVTag tempVector start |
  maybeTVTag := stack last.
  ((maybeTVTag isMemberOf: Association)
  and: [maybeTVTag key == #pushNewArray]) ifTrue:
  [blockStartsToTempVars notNil "implies we were intialized with temp names."
  ifTrue: "Use the provided temps"
  [self assert: ((tempVector := tempVars at: offset + 1 ifAbsent: [ParseNode basicNew]) isTemp
  and: [tempVector isIndirectTempVector
  and: [tempVector remoteTemps size = maybeTVTag value size]])]
  ifFalse: "Synthesize some remote temps"
  [tempVector := maybeTVTag value.
  offset + 1 <= tempVars size
  ifTrue:
  [start := 2.
  tempVector at: 1 put: (tempVars at: offset + 1)]
  ifFalse:
  [tempVars := (Array new: offset + 1)
  replaceFrom: 1
  to: tempVars size
  with: tempVars.
  start := 1].
  start to: tempVector size do:
+ [:i| | uniqueName |
+ uniqueName := 't', (tempVarCount + i) printString.
+ [constructor instVars includes: uniqueName] whileTrue: [uniqueName := 't', uniqueName].
- [:i|
  tempVector
  at: i
  put: (constructor
  codeTemp: numLocalTemps + offset + i - 1
+ named: uniqueName)].
- named: 't', (tempVarCount + i) printString)].
  tempVars at: offset + 1 put: (constructor codeRemoteTemp: offset + 1 remoteTemps: tempVector)].
  tempVarCount := tempVarCount + maybeTVTag value size.
  stack removeLast.
  ^self].
  self pushTemporaryVariable: offset; doStore: statements!

Item was changed:
  ----- Method: DecompilerConstructor>>codeInst: (in category 'constructor') -----
  codeInst: index
 
  ^InstanceVariableNode new
+ name: (instVars at: index + 1 ifAbsent:
+ [(UndeclaredVariableWarning new
+ name: 'instVar with index ', (index + 1) asString
+ selector: method selector
+ class: method methodClass) signal.
+ 'unknownInstanceVariableNameAtIndex', (index + 1) asString])
- name: (instVars at: index + 1 ifAbsent: ['unknown', index asString])
  index: index + 1!

Item was added:
+ ----- Method: DecompilerConstructor>>instVars (in category 'constructor') -----
+ instVars
+
+ ^instVars!

Item was changed:
  ----- Method: DecompilerConstructorForClosures>>codeRemoteTemp:remoteTemps: (in category 'constructor') -----
  codeRemoteTemp: index remoteTemps: tempVector
 
+ | uniqueName |
+ uniqueName := 'r', index printString.
+ [instVars includes: uniqueName] whileTrue: [uniqueName := 'r', uniqueName].
  ^(RemoteTempVectorNode new
+ name: uniqueName
- name: '_r', index printString
  index: index
  type: LdTempType
  scope: 0)
  remoteTemps: tempVector;
  yourself!