MCPcopy Index your code
hub / github.com/RustPython/RustPython / mark_except_handlers

Function mark_except_handlers

crates/codegen/src/ir.rs:2083–2099  ·  view source on GitHub ↗

Mark exception handler target blocks. flowgraph.c mark_except_handlers

(blocks: &mut [Block])

Source from the content-addressed store, hash-verified

2081/// Mark exception handler target blocks.
2082/// flowgraph.c mark_except_handlers
2083pub(crate) fn mark_except_handlers(blocks: &mut [Block]) {
2084 // Reset handler flags
2085 for block in blocks.iter_mut() {
2086 block.except_handler = false;
2087 block.preserve_lasti = false;
2088 }
2089 // Mark target blocks of SETUP_* as except handlers
2090 let targets: Vec<usize> = blocks
2091 .iter()
2092 .flat_map(|b| b.instructions.iter())
2093 .filter(|i| i.instr.is_block_push() && i.target != BlockIdx::NULL)
2094 .map(|i| i.target.idx())
2095 .collect();
2096 for idx in targets {
2097 blocks[idx].except_handler = true;
2098 }
2099}
2100
2101/// flowgraph.c mark_cold
2102fn mark_cold(blocks: &mut [Block]) {

Callers 1

finalize_codeMethod · 0.85

Calls 7

collectMethod · 0.80
is_block_pushMethod · 0.80
idxMethod · 0.80
iter_mutMethod · 0.45
mapMethod · 0.45
filterMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected