[squeak-dev] Decompiler failure

Levente Uzonyi leves at elte.hu
Tue Nov 4 00:23:58 UTC 2014

On Mon, 3 Nov 2014, Tobias Pape wrote:

> Hey all
> the following code fails to be decompiled by the
> Decompiler and I have no clue:
> retryOnce: aTryBlock
> 	| retry |
> 	retry := true.
> 	[[retry] whileTrue: [|result|
> 		result := aTryBlock value.
> 		retry := false.
> 		^ result
> 	]] on: Error do: [:e |
> 		retry := (e isKindOf: NetworkError) not
> 	].
> Apparently, the Decompilers stack is empty but it tries to access
> its last element, which results in an indexing error.

The problem is that BlockLocalTempCounter tempCountForBlockStartingAt: pc 
in: method returns 67 (the value of its stackPointer) instead of 1 (the 
number of local temporaries in the first block of the method) in 
#doClosureCopyCopiedValues:numArgs:blockSize: when pc is 50.

It seems to me that it's a bug in BlockLocalTempCounter >> #doJoin, 
because it sets its own stackPointer to a pc value.
Decompilation works for me with the following implementation:

 	scanner pc < blockEnd ifTrue: [
 		joinOffsets at: scanner pc ifPresent: [ :sp | stackPointer := sp ] ]

The comment of the methods tells something about the #ifAbsent: branch, 
but I don't see how that should work.

Also the comment in #tempCountForBlockAt:in: says

 	There are short-cuts.  The ones we take here are
 		- if there is no sequence of push nils there can be no local temps
 		- we follow forward jumps to shorten the amount of scanning

But it seems to me that the second part is not implemented.


> Best
> 	-Tobias

More information about the Squeak-dev mailing list