compiler.cfg.save-contexts: context-save-needed not needed because it's
the same as gc-map-insndb4
							parent
							
								
									3f9fa7e39e
								
							
						
					
					
						commit
						bdc4880b17
					
				| 
						 | 
				
			
			@ -5,21 +5,21 @@ IN: compiler.cfg.save-contexts
 | 
			
		|||
HELP: insert-save-contexts
 | 
			
		||||
{ $values { "cfg" cfg } }
 | 
			
		||||
{ $description "Inserts " { $link ##save-context } " instructions in each " { $link basic-block } " in the cfg that needs them. Save contexts are needed after instructions that modify the context, or instructions that read parameter registers." }
 | 
			
		||||
{ $see-also context-save-needed } ;
 | 
			
		||||
{ $see-also insns-needs-save-context? } ;
 | 
			
		||||
 | 
			
		||||
HELP: insns-needs-save-context?
 | 
			
		||||
{ $values { "insns" sequence } { "?" boolean } }
 | 
			
		||||
{ $description "Whether to insert a " { $link ##save-context } " instruction in the given instruction sequence or not." }
 | 
			
		||||
{ $see-also context-save-needed } ;
 | 
			
		||||
 | 
			
		||||
HELP: context-save-needed
 | 
			
		||||
{ $class-description "Union class of all instructions that needs to be preceeded by a " { $link ##save-context } " instruction. Only instructions that can allocate memory mandates save contexts." } ;
 | 
			
		||||
{ $description "Whether to insert a " { $link ##save-context } " instruction in the given instruction sequence or not. Only instructions that can allocate memory mandates save contexts." }
 | 
			
		||||
{ $see-also gc-map-insn } ;
 | 
			
		||||
 | 
			
		||||
HELP: save-context-offset
 | 
			
		||||
{ $values { "insns" sequence } { "n" integer } }
 | 
			
		||||
{ $description { $link ##save-context } " must be placed after instructions that modify the context, or instructions that read parameter registers." } ;
 | 
			
		||||
 | 
			
		||||
ARTICLE: "compiler.cfg.save-contexts" "Insert context saves"
 | 
			
		||||
"Inserts " { $link ##save-context } " in blocks that need them." ;
 | 
			
		||||
"Inserts " { $link ##save-context } " in blocks that need them."
 | 
			
		||||
$nl
 | 
			
		||||
"Main word:"
 | 
			
		||||
{ $subsections insert-save-contexts } ;
 | 
			
		||||
 | 
			
		||||
ABOUT: "compiler.cfg.save-contexts"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,17 @@ compiler.cfg.save-contexts kernel namespaces tools.test
 | 
			
		|||
cpu.x86.assembler.operands cpu.architecture ;
 | 
			
		||||
IN: compiler.cfg.save-contexts.tests
 | 
			
		||||
 | 
			
		||||
! insns-needs-save-context?
 | 
			
		||||
{ t f } [
 | 
			
		||||
    {
 | 
			
		||||
        T{ ##call-gc }
 | 
			
		||||
    } insns-needs-save-context?
 | 
			
		||||
    {
 | 
			
		||||
        T{ ##add f 1 2 3 }
 | 
			
		||||
        T{ ##branch }
 | 
			
		||||
    } insns-needs-save-context?
 | 
			
		||||
] unit-test
 | 
			
		||||
 | 
			
		||||
H{ } clone representations set
 | 
			
		||||
 | 
			
		||||
V{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,13 +5,12 @@ cpu.architecture kernel sequences ;
 | 
			
		|||
IN: compiler.cfg.save-contexts
 | 
			
		||||
 | 
			
		||||
UNION: context-modifier ##phi ##inc ##callback-inputs ;
 | 
			
		||||
UNION: context-save-needed gc-map-insn ;
 | 
			
		||||
 | 
			
		||||
: save-context-offset ( insns -- n )
 | 
			
		||||
    [ context-modifier? not ] find drop ;
 | 
			
		||||
 | 
			
		||||
: insns-needs-save-context? ( insns -- ? )
 | 
			
		||||
    [ context-save-needed? ] any? ;
 | 
			
		||||
    [ gc-map-insn? ] any? ;
 | 
			
		||||
 | 
			
		||||
: insert-save-context ( insns -- insns' )
 | 
			
		||||
    dup insns-needs-save-context? [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue