[Cuis-dev] [bug?] Decompiler does not restore unused temporary variables
Juan Vuletich
juan at cuis.st
Wed May 7 05:45:46 PDT 2025
Nice. Integrated.
Thanks!
On 5/6/2025 7:22 PM, Hernán Wilkinson via Cuis-dev wrote:
> Hi,
> attached is a change I propose to DecompilerTests (it should be
> called DecompilerTest, singular, a change I did not include to
> facilitate merging).
> Currently DecompilerTests decompiles all classes in the image. This
> contradicts a testing rule that is that "the test must be in control
> of everything". In these tests, they do not control the setup because
> the decompiled classes will change based on the classes in the image,
> that is the reason Nico, me and for sure other people get a test
> failure when running that test.
> To minimize the impact I changed the tests to run only on the base
> classes, that is classes on Kernel, Graphics, System, etc.
> BTW, I don't know what DecompilerTestFailuresCollector is there
> for... it has no tests and no references...
>
> Cheers!
> Hernan.
>
> On Mon, May 5, 2025 at 1:13 PM Juan Vuletich via Cuis-dev
> <cuis-dev at lists.cuis.st <mailto:cuis-dev at lists.cuis.st>> wrote:
>
> On 5/5/2025 1:04 PM, Nicolás Papagna Maldonado via Cuis-dev wrote:
>> Hi Juan, all!
>>
>> Thanks for the clarification.
>>
>> CodeCoverage de-optimizes methods to do its thing, so
>> CodeCoverageTest temporaryVariable is actually a valid use-case
>> (it's used to check whether the temporary variable declaration is
>> marked as 'covered' when the variable is read.
>>
>> Is there any way I can exclude such tests from DecompilerTests?
>> I'm building a custom image where I need to check that I didn't
>> break any tests in the base image and that failing tests is
>> breaking my CI builds, preventing the build from suceeding.
>>
>> Cheers!
>> Nico PM
>
> Yes, you can add it to #expectedFailures . BaseImageTests has some
> examples of this.
>
> Cheers,
>
>>
>> On Mon, May 5, 2025 at 12:54 PM Juan Vuletich <juan at cuis.st
>> <mailto:juan at cuis.st>> wrote:
>>
>> Hi Nico.
>>
>> I don't think this is a bug. Decompiler creates Smalltalk
>> code from actual bytecode. Dead code had been removed when
>> generating the bytecode. Looks fine to me.
>>
>> Does it make sense to add some use of the 'a' variable, so it
>> is kept during compilation? I mean, it is difficult to
>> imagine that CodeCoverageTest can do something interesting
>> with a method that had all its code optimized out...
>>
>> Cheers,
>>
>> On 5/4/2025 1:49 PM, Nicolás Papagna Maldonado via Cuis-dev
>> wrote:
>>> Hi folks,
>>>
>>> I don't know if this is a bug or the expected behavior.
>>>
>>> Today I ran the tests in BaseImageTests with the
>>> CodeCoverage package
>>> (https://github.com/npapagna/cuis-code-coverage) loaded and
>>> one of the DecompilerTests failed.
>>> The reason seems to be that Decompiler does not restore
>>> unused temporary variables.
>>>
>>> In particular,
>>> DecompilerTests>>#testDecompilerInClassesCNtoCZ was failing
>>> on CodeCoverageTest temporaryVariable:
>>> (For context: this method is needed to reproduce a test
>>> scenario for the CodeCoverage tool)
>>>
>>> CodeCoverageTest >> #temporaryVariable
>>> | a |
>>> a.
>>>
>>> To reproduce without the CodeCoverage package, evaluate:
>>>
>>> Object compile: 'm1 |a| a'.
>>>
>>> newCodeString := (Decompiler new
>>> decompile: #m1
>>> in: Object
>>> method: Object >> #m1) decompileString.
>>>
>>> Notice that newCodeString is 'm1 ^ self.' and it should be
>>> 'm1 |a| a'(if this is really a bug).
>>>
>>> The code above was run on HEAD at the moment
>>> (6c13d4eda2e9a8c56362ae3363d7b013917227c5).
>>>
>>> Is this something that needs to be fixed?
>>>
>>> Best,
>>> Nico PM
>>
>>
>> --
>> Juan Vuletich
>> www.cuis-smalltalk.org <http://www.cuis-smalltalk.org>
>> https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
>> https://github.com/jvuletich
>> https://www.linkedin.com/in/juan-vuletich-75611b3
>> https://independent.academia.edu/JuanVuletich
>> https://www.researchgate.net/profile/Juan-Vuletich
>> https://patents.justia.com/inventor/juan-manuel-vuletich
>> https://twitter.com/JuanVuletich
>>
>>
>>
>> --
>>
>> Nicolás Papagna
>
>
> --
> Juan Vuletich
> cuis.st <http://cuis.st>
> github.com/jvuletich <http://github.com/jvuletich>
> researchgate.net/profile/Juan-Vuletich <http://researchgate.net/profile/Juan-Vuletich>
> independent.academia.edu/JuanVuletich <http://independent.academia.edu/JuanVuletich>
> patents.justia.com/inventor/juan-manuel-vuletich <http://patents.justia.com/inventor/juan-manuel-vuletich>
> linkedin.com/in/juan-vuletich-75611b3 <http://linkedin.com/in/juan-vuletich-75611b3>
> twitter.com/JuanVuletich <http://twitter.com/JuanVuletich>
>
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st <mailto:Cuis-dev at lists.cuis.st>
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>
>
>
> --
> *Hernán Wilkinson
> Agile Software Development, Teaching & Coaching*
> *Phone: +54-011*-4893-2057
> *Twitter: @HernanWilkinson*
> *site: http://www.10Pines.com <http://www.10pines.com/>*
> Address: Alem 896, Floor 6, Buenos Aires, Argentina
--
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250507/c4662b62/attachment-0001.htm>
More information about the Cuis-dev
mailing list