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

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

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

Name: Compiler-eem.240
Author: eem
Time: 6 November 2012, 1:15:13.684 pm
UUID: 7b6bc3de-112b-442d-8f73-3cafe5819fbc
Ancestors: Compiler-eem.239

Have the decompiler map whileTrue/False: [] to whileTrue/False
instead of relying on MethodNode.  Fixes decompiler tests
after fixing printing of whileTrue/False: [] to be side-effect free
in Compiler-eem.239.

=============== Diff against Compiler-eem.239 ===============

Item was changed:
  ----- Method: Decompiler>>jump:if: (in category 'instruction decoding') -----
  jump: dist if: condition
 
  | savePc sign elsePc elseStart end cond ifExpr thenBlock elseBlock
+  thenJump elseJump condHasValue isIfNil saveStack blockBody blockArgs |
-  thenJump elseJump condHasValue isIfNil saveStack blockBody |
  lastJumpIfPcStack addLast: lastPc.
  stack last == CascadeFlag ifTrue: [^ [self case: dist] ensure: [lastJumpIfPcStack removeLast]].
  elsePc := lastPc.
  elseStart := pc + dist.
  end := limit.
  "Check for bfp-jmp to invert condition.
  Don't be fooled by a loop with a null body."
  sign := condition.
  savePc := pc.
  self interpretJump ifNotNil:
  [:elseDist|
  (elseDist >= 0 and: [elseStart = pc]) ifTrue:
  [sign := sign not.  elseStart := pc + elseDist]].
  pc := savePc.
  ifExpr := stack removeLast.
  (isIfNil := stack size > 0 and: [stack last == IfNilFlag]) ifTrue:
  [stack removeLast].
  saveStack := stack.
  stack := OrderedCollection new.
  thenBlock := self blockTo: elseStart.
  condHasValue := hasValue or: [isIfNil].
  "ensure jump is within block (in case thenExpr returns)"
  thenJump := exit <= end ifTrue: [exit] ifFalse: [elseStart].
  "if jump goes back, then it's a loop"
  thenJump < elseStart
  ifTrue:
  ["Must be a while loop...
   thenJump will jump to the beginning of the while expr.  In the case of while's
   with a block in the condition, the while expr should include more than just
   the last expression: find all the statements needed by re-decompiling."
  stack := saveStack.
  pc := thenJump.
  blockBody := self statementsTo: elsePc.
  "discard unwanted statements from block"
  blockBody size - 1 timesRepeat: [statements removeLast].
+ blockArgs := thenBlock statements = constructor codeEmptyBlock statements
+ ifTrue: [#()]
+ ifFalse: [{ thenBlock }].
  statements addLast:
  (constructor
  codeMessage: (constructor codeBlock: blockBody returns: false)
  selector: (constructor
+ codeSelector: (blockArgs isEmpty
+ ifTrue:
+ [sign
+ ifTrue: [#whileFalse]
+ ifFalse: [#whileTrue]]
+ ifFalse:
+ [sign
+ ifTrue: [#whileFalse:]
+ ifFalse: [#whileTrue:]])
- codeSelector: (sign
- ifTrue: [#whileFalse:]
- ifFalse: [#whileTrue:])
  code: #macro)
+ arguments: blockArgs).
- arguments: { thenBlock }).
  pc := elseStart.
  self convertToDoLoop]
  ifFalse:
  ["Must be a conditional..."
  elseBlock := self blockTo: thenJump.
  elseJump := exit.
  "if elseJump is backwards, it is not part of the elseExpr"
  elseJump < elsePc ifTrue:
  [pc := lastPc].
  cond := isIfNil
  ifTrue:
  [constructor
  codeMessage: ifExpr ifNilReceiver
  selector: (constructor
  codeSelector: (sign ifTrue: [#ifNotNil:] ifFalse: [#ifNil:])
  code: #macro)
  arguments: (Array with: thenBlock)]
  ifFalse:
  [constructor
  codeMessage: ifExpr
  selector: (constructor codeSelector: #ifTrue:ifFalse: code: #macro)
  arguments: (sign
  ifTrue: [{elseBlock. thenBlock}]
  ifFalse: [{thenBlock. elseBlock}])].
  stack := saveStack.
  condHasValue
  ifTrue: [stack addLast: cond]
  ifFalse: [statements addLast: cond]].
  lastJumpIfPcStack removeLast.!