egallesio / STklos

STklos Scheme
http://stklos.net
GNU General Public License v2.0
69 stars 17 forks source link

Add a parameter to control the peephole optimizer #583

Closed jpellegrini closed 6 months ago

jpellegrini commented 1 year ago

Hi @egallesio ! I know you're busy working on the 2.0 release -- I think this one could be done later. But I thought I'd make the PR anyway...

This makes the peephole-optimization pass optional -- this could be interesting for debugging and profiling, perhaps. :)

stklos> (compiler:peephole-optimizer )
#t
stklos> (disassemble-expr '(+ a #f) #t )

000:  GLOBAL-REF-PUSH      0
002:  IM-FALSE            
003:  IN-ADD2             
004:

Constants:
0: a
stklos> (compiler:peephole-optimizer #f)
stklos> (disassemble-expr '(+ a #f) #t )

000:  GLOBAL-REF           0
002:  PUSH                
003:  IM-FALSE            
004:  IN-ADD2             
005:

Constants:
0: a
jpellegrini commented 1 year ago

Sorry for closing and reopening. That was not intentional.

egallesio commented 6 months ago

Also merged this one (not detected by GitHub).

I also added the new parameter to the stklos and stklos-compile commands as a new flag. Not sure if this is a good idea, as I don't see any reason not to use it all the time (and it makes the commands more complex). What do you think?

Thanks for the PR.