compiler.cfg.save-contexts: ##save-context isn't need in front of ##call-gc
The reason is because the minor-gc primitive itself saves the context. Not inlining context saves, saves 20 bytes/call site.locals-and-roots
parent
63ef600aa3
commit
07aee7525f
|
@ -1,5 +1,5 @@
|
||||||
USING: compiler.cfg compiler.cfg.instructions help.markup help.syntax
|
USING: compiler.cfg compiler.cfg.instructions help.markup help.syntax
|
||||||
math sequences kernel ;
|
kernel math memory sequences ;
|
||||||
IN: compiler.cfg.save-contexts
|
IN: compiler.cfg.save-contexts
|
||||||
|
|
||||||
HELP: insert-save-contexts
|
HELP: insert-save-contexts
|
||||||
|
@ -17,9 +17,10 @@ HELP: save-context-offset
|
||||||
{ $description { $link ##save-context } " must be placed after instructions that modify the context, or instructions that read parameter registers." } ;
|
{ $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"
|
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. If an instruction does something that might trigger a GC sweep, such as calling a C function, then the context must be saved before."
|
||||||
$nl
|
$nl
|
||||||
"Main word:"
|
"Main word:"
|
||||||
{ $subsections insert-save-contexts } ;
|
{ $subsections insert-save-contexts }
|
||||||
|
{ $notes "The " { ##call-gc } " instruction does not need a context save because the primitive implementing the instruction (" { $link minor-gc } ") already saves the context for us." } ;
|
||||||
|
|
||||||
ABOUT: "compiler.cfg.save-contexts"
|
ABOUT: "compiler.cfg.save-contexts"
|
||||||
|
|
|
@ -5,7 +5,7 @@ cpu.x86.assembler.operands cpu.architecture ;
|
||||||
IN: compiler.cfg.save-contexts.tests
|
IN: compiler.cfg.save-contexts.tests
|
||||||
|
|
||||||
! insns-needs-save-context?
|
! insns-needs-save-context?
|
||||||
{ t f } [
|
{ f f t } [
|
||||||
{
|
{
|
||||||
T{ ##call-gc }
|
T{ ##call-gc }
|
||||||
} insns-needs-save-context?
|
} insns-needs-save-context?
|
||||||
|
@ -13,6 +13,7 @@ IN: compiler.cfg.save-contexts.tests
|
||||||
T{ ##add f 1 2 3 }
|
T{ ##add f 1 2 3 }
|
||||||
T{ ##branch }
|
T{ ##branch }
|
||||||
} insns-needs-save-context?
|
} insns-needs-save-context?
|
||||||
|
{ T{ ##alien-invoke } } insns-needs-save-context?
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
H{ } clone representations set
|
H{ } clone representations set
|
||||||
|
|
|
@ -9,8 +9,14 @@ UNION: context-modifier ##phi ##inc ##callback-inputs ;
|
||||||
: save-context-offset ( insns -- n )
|
: save-context-offset ( insns -- n )
|
||||||
[ context-modifier? not ] find drop ;
|
[ context-modifier? not ] find drop ;
|
||||||
|
|
||||||
|
UNION: needs-save-context-insn
|
||||||
|
##alien-invoke
|
||||||
|
##alien-indirect
|
||||||
|
##box-long-long
|
||||||
|
##box ;
|
||||||
|
|
||||||
: insns-needs-save-context? ( insns -- ? )
|
: insns-needs-save-context? ( insns -- ? )
|
||||||
[ gc-map-insn? ] any? ;
|
[ needs-save-context-insn? ] any? ;
|
||||||
|
|
||||||
: insert-save-context ( insns -- insns' )
|
: insert-save-context ( insns -- insns' )
|
||||||
dup insns-needs-save-context? [
|
dup insns-needs-save-context? [
|
||||||
|
|
Loading…
Reference in New Issue