brianfeaster / worldtm

Automatically exported from code.google.com/p/worldtm
0 stars 0 forks source link

Scheme compiler #32

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The current compiler, which translates Scheme at runtime into the virtual 
machine's RTL ,is very basic and non expandable.  It will be replaced by a 
proper compiler module and optimizing infrastructure.

Optimized code blocks could become invalidated after expression or variable 
mutation should be handled by recompiling at runtime.  Example:
(define fn +)
(define (fun x y) (fn x y))
(set! fn -) ; Cause fun's code block to be recompiled if fn was inlined
(fun 5 3)
=> 2

Original issue reported on code.google.com by bri...@gmail.com on 18 Aug 2011 at 6:35

GoogleCodeExporter commented 8 years ago
r177 has the updated compiler.  Still required are optimizing functions to be 
added to the assembler module.

Original comment by bri...@gmail.com on 6 Oct 2011 at 9:02

GoogleCodeExporter commented 8 years ago
r178 will optimize out specific cases of redundant pop/push icode instructions 
in an iblock.  For example:

...
pop $4
pop $5
sti $0 $1 5
push $5
push $4
...

will mutate the pops and pushs to NOPs in the iblock.  The assembler will then 
skip those icodes.

Original comment by bri...@gmail.com on 7 Oct 2011 at 2:57

GoogleCodeExporter commented 8 years ago
r181 optimizes away empty iblocks which are removed from the igraph.

#<000  2b644e4d2040  [001]  [001]  ()
  00  beqi $0 #<0> #<0>>

#<001  2b644e4d2040  [002]  [---]  (000 000)>

#<002  2b644e4d2040  [003]  [---]  (001)
  00  mv   $0 $1>

The result:
#<000  2b644e4d2040  [002]  [002]  ()
  00  beqi $0 #<0> #<0>>

#<001  ---  [002]  [---]  (000 000)>

#<002  2b644e4d2040  [003]  [---]  (000 000)
  00  mv   $0 $1>

Original comment by bri...@gmail.com on 12 Oct 2011 at 4:16

GoogleCodeExporter commented 8 years ago
Key:
#<iblock  tag_value  [default child iblock] [conditional child iblock] (list of 
parent blocks)
 icodes
 ...>

Original comment by bri...@gmail.com on 13 Oct 2011 at 7:30

GoogleCodeExporter commented 8 years ago
Push/pop and pop/push optimization have been included along with a test in r190 
to verify they occur on the same iblock.  Icodes were replaced with NOP 
instructions which weren't emitted during final assembly but having NOPs is 
useful.  They are no longer used to replaced unneeded icodes (NA is used 
instead) and are emitted in the final assembly if included in the initial 
assembly instruction list.

Original comment by bri...@gmail.com on 30 Oct 2011 at 8:02