2015-01-22 15:30:49 -05:00
USING: compiler.cfg compiler.cfg.instructions help.markup
help.syntax kernel sequences strings ;
2015-01-19 08:08:37 -05:00
IN: compiler.cfg.stacks.clearing
ARTICLE: "compiler.cfg.stacks.clearing" "Uninitialized stack location clearing"
"A compiler pass that inserts " { $link ##replace-imm } " instructions front of unsafe " { $link ##peek } " instructions in the " { $link cfg } ". Consider the following sequence of instructions."
{ $code
2015-03-03 17:45:47 -05:00
"##inc D 2"
2015-01-19 08:08:37 -05:00
"##peek RCX D 2"
}
"The ##peek can cause a stack underflow and then there will be two uninitialized locations on the data stack that can't be traced. To counteract that, this pass modifies the instruction sequence so that it becomes:"
{ $code
2015-03-03 17:45:47 -05:00
"##inc D 2"
2015-01-19 08:08:37 -05:00
"##replace-imm 17 D 0"
"##replace-imm 17 D 1"
"##peek RCX D 2"
} ;
HELP: dangerous-insn?
2015-01-22 15:30:49 -05:00
{ $values { "state" "a stack state" } { "insn" insn } { "?" boolean } }
2015-01-19 08:08:37 -05:00
{ $description "Checks if the instruction is dangerous (can cause a stack underflow). " }
{ $examples
{ $example
2015-01-22 15:30:49 -05:00
"USING: compiler.cfg.instructions compiler.cfg.registers compiler.cfg.stacks.clearing prettyprint ;"
2015-01-19 08:08:37 -05:00
"{ { 0 { } } { 0 { } } } T{ ##peek { loc D 0 } } dangerous-insn? ."
"t"
}
{ $example
2015-01-22 15:30:49 -05:00
"USING: compiler.cfg.instructions compiler.cfg.registers compiler.cfg.stacks.clearing prettyprint ;"
2015-01-19 08:08:37 -05:00
"{ { 0 { } } { 2 { 0 1 } } } T{ ##peek { loc R 0 } } dangerous-insn? ."
"f"
}
} ;
ABOUT: "compiler.cfg.stacks.clearing"