]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/cfg/save-contexts/save-contexts.factor
GC maps for more compact inline GC checks
[factor.git] / basis / compiler / cfg / save-contexts / save-contexts.factor
1 ! Copyright (C) 2009, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors combinators.short-circuit
4 compiler.cfg.instructions compiler.cfg.registers
5 compiler.cfg.rpo cpu.architecture kernel sequences vectors ;
6 IN: compiler.cfg.save-contexts
7
8 ! Insert context saves.
9
10 : needs-save-context? ( insns -- ? )
11     [
12         {
13             [ ##unary-float-function? ]
14             [ ##binary-float-function? ]
15             [ ##alien-invoke? ]
16             [ ##alien-indirect? ]
17             [ ##alien-assembly? ]
18         } 1||
19     ] any? ;
20
21 : insert-save-context ( bb -- )
22     dup instructions>> dup needs-save-context? [
23         tagged-rep next-vreg-rep
24         tagged-rep next-vreg-rep
25         \ ##save-context new-insn prefix
26         >>instructions drop
27     ] [ 2drop ] if ;
28
29 : insert-save-contexts ( cfg -- cfg' )
30     dup [ insert-save-context ] each-basic-block ;