[Vm-dev] (Squeak) Compiler bug?
Florin Mateoc
florin.mateoc at gmail.com
Mon Jan 9 19:55:35 UTC 2023
Yes, spooky action at a distance :)
On Mon, Jan 9, 2023 at 1:45 PM Eliot Miranda <eliot.miranda at gmail.com>
wrote:
>
> Hi Florin,
>
> I've found the issue, which is an infinite loop in the Decompiler for
> your undecompilable version. Strangely enough it has nothing to do with
> the code you modify. It has to do with the middle ifTrue: of the three at
> the end of the final block:
>
> mm1 eventHandler
> ifNotNil: [(morphs includesAllOf: mm1 eventHandler
> allRecipients)
> ifTrue: [mm1 eventHandler: nil]].
>
>
> *mm1 isMorphicModel ifTrue: [mm1 model
> isMorphicModel ifTrue: [mm1 model
> breakDependents]].*
> mm1 isTextMorph
> ifTrue: [mm1 setContainer: nil]]].
>
> I can fix it for this one method, but not without breaking decompilation
> of about 40 other methods. So I need to understand it better. Give me a
> few days. I've called on a higher power (the original author is Dan
> himself). So hopefully we'll get this sorted very soon.
>
> On Sun, Jan 8, 2023 at 7:01 PM Florin Mateoc <florin.mateoc at gmail.com>
> wrote:
>
>>
>> Hi,
>>
>> Happy New Year everybody!
>>
>> I hope you will forgive my transgression, I know this is not about the
>> VM, it is about the bytecode compiler, but I am only subscribed to this
>> list, and the Squeak compiler is somewhere in between.
>>
>> I have recently stumbled upon a regression introduced by Compiler-eem.483
>> One of my generated (transformed) methods is apparently valid Smalltalk -
>> it can still be compiled - but it cannot be decompiled anymore. I am not
>> sure if this is a compiler bug, or a latent decompiler bug exposed by the
>> changes in Compiler-eem.483
>>
>> My method is below, it is a transformed variant of
>> NativeImageSegment>>findRogueRootsPrep
>>
>> The bug is somehow caused by the literal #Marker. I have started at the
>> bytecodes and they look ok to me, but the decompiler enters an (apparently
>> unrelated) infinite loop. It is also not just about the literal itself or
>> the immediate surrounding code, the method needs to be big/complex enough
>> (over a certain number of literals?) to trigger the bug.
>>
>>
>> findRogueRootsPrep1
>> "Part of the tool to track down unwanted pointers into the segment.
>> Break all owner pointers in submorphs, scripts, and viewers in flaps."
>> | wld players morphs |
>> wld := arrayOfRoots detect: [:obj | obj isMorph and: [obj isWorldMorph]]
>> ifNone: [].
>> wld == nil ifTrue: [
>> (wld := arrayOfRoots
>> detect: [:obj1 | obj1 isMorph]
>> ifNone: [#Marker]
>> ) == #Marker ifTrue: [
>> ^ self error: 'can''t find a root morph']].
>> morphs := IdentitySet new: 400.
>> wld allMorphsAndBookPagesInto: morphs.
>> players := wld presenter allExtantPlayers. "just the cached list"
>> players do: [:pp | | scriptEditors |
>> scriptEditors := pp class tileScriptNames collect: [:nn | pp
>> scriptEditorFor: nn].
>> scriptEditors do: [:se | morphs addAll: se allMorphs]].
>> wld submorphs do: [:mm | "non showing flaps"
>> (mm isKindOf: FlapTab) ifTrue: [
>> mm referent allMorphsAndBookPagesInto: morphs]].
>> morphs do: [:mm1 | "break the back pointers"
>> mm1 isInMemory ifTrue: [
>> (mm1 respondsTo: #target) ifTrue: [
>> mm1 nearestOwnerThat: [:ow | | zzzTemp |
>> ow == mm1 target ifTrue: [
>> mm1 target: nil.
>> zzzTemp := true
>> ] ifFalse: [
>> zzzTemp := false].
>> zzzTemp]].
>> (mm1 respondsTo: #arguments) ifTrue: [
>> mm1 arguments do: [:arg |
>> arg == nil ifFalse: [
>> mm1 nearestOwnerThat: [:ow1 | | zzzTemp1 |
>> ow1 == arg ifTrue: [
>> mm1 arguments at: (mm1 arguments indexOf: arg) put: nil.
>> zzzTemp1 := true
>> ] ifFalse: [
>> zzzTemp1 := false].
>> zzzTemp1]]]].
>> mm1 eventHandler == nil ifFalse: ["recipients point back up"
>> (morphs includesAllOf: mm1 eventHandler allRecipients) ifTrue: [
>> mm1 eventHandler: nil]].
>> "temporary, until using Model for PartsBin"
>> mm1 isMorphicModel ifTrue: [
>> mm1 model isMorphicModel ifTrue: [
>> mm1 model breakDependents]].
>> mm1 isTextMorph ifTrue: [
>> mm1 setContainer: nil]]].
>> (Smalltalk includesKey: #Owners) ifTrue: [
>> Smalltalk at: #Owners put: nil].
>> "in case findOwnerMap: is commented out"
>> "self findOwnerMap: morphs."
>> morphs do: [:mm2 | "break the back pointers"
>> mm2 isInMemory ifTrue: [
>> mm2 privateOwner: nil]]
>>
>>
>> Florin
>>
>
>
> --
> _,,,^..^,,,_
> best, Eliot
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20230109/e4d9d5f3/attachment.html>
More information about the Vm-dev
mailing list