chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] Fix excessive use of temporaries in emitted co


From: Peter Bex
Subject: [Chicken-hackers] [PATCH] Fix excessive use of temporaries in emitted code
Date: Sun, 28 Feb 2016 18:36:01 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hi all,

While digging in the "stack overflow" issue I pointed out in the other
thread, I came across an oddity; one of the functions in compiler.c
(which comes from compiler.scm) received over 200 temporaries, while
it used less than 100.

It turns out that the temporaries are counted very simply by walking
the code, for each binding we increment the number of temporaries by 1.
However, the code generator will re-use temporaries: the temporary
counter "i" is only incremented for the duration of a walk of a
##core#bind node.  AFAICT the only situation where a binding can really
be re-used is when entering and exiting an IF/ELSE arm, so attached
is a very simple patch which takes the maximum of the used temporaries
in each arm, just like we do for counting allocations.

Unfortunately, this is not what's causing the stack overflow.  Probably
gcc sees that these variables are unused anyway.  But it does unclutter
the generated C code, which helps when you're trying to read that.

Cheers,
Peter

Attachment: 0001-Fix-excessive-temporary-generation.chicken-5.patch
Description: Text Data

Attachment: 0001-Fix-excessive-temporary-generation.master.patch
Description: Text Data

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]