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

Function mark_cold

crates/codegen/src/ir.rs:2102–2140  ·  view source on GitHub ↗

flowgraph.c mark_cold

(blocks: &mut [Block])

Source from the content-addressed store, hash-verified

2100
2101/// flowgraph.c mark_cold
2102fn mark_cold(blocks: &mut [Block]) {
2103 let n = blocks.len();
2104 let mut warm = vec![false; n];
2105 let mut queue = VecDeque::new();
2106
2107 warm[0] = true;
2108 queue.push_back(BlockIdx(0));
2109
2110 while let Some(block_idx) = queue.pop_front() {
2111 let block = &blocks[block_idx.idx()];
2112
2113 let has_fallthrough = block
2114 .instructions
2115 .last()
2116 .map(|ins| !ins.instr.is_scope_exit() && !ins.instr.is_unconditional_jump())
2117 .unwrap_or(true);
2118 if has_fallthrough && block.next != BlockIdx::NULL {
2119 let next_idx = block.next.idx();
2120 if !blocks[next_idx].except_handler && !warm[next_idx] {
2121 warm[next_idx] = true;
2122 queue.push_back(block.next);
2123 }
2124 }
2125
2126 for instr in &block.instructions {
2127 if instr.target != BlockIdx::NULL {
2128 let target_idx = instr.target.idx();
2129 if !blocks[target_idx].except_handler && !warm[target_idx] {
2130 warm[target_idx] = true;
2131 queue.push_back(instr.target);
2132 }
2133 }
2134 }
2135 }
2136
2137 for (i, block) in blocks.iter_mut().enumerate() {
2138 block.cold = !warm[i];
2139 }
2140}
2141
2142/// flowgraph.c push_cold_blocks_to_end
2143fn push_cold_blocks_to_end(blocks: &mut Vec<Block>) {

Callers 1

push_cold_blocks_to_endFunction · 0.85

Calls 10

newFunction · 0.85
BlockIdxClass · 0.85
pop_frontMethod · 0.80
idxMethod · 0.80
is_scope_exitMethod · 0.80
is_unconditional_jumpMethod · 0.80
lenMethod · 0.45
mapMethod · 0.45
lastMethod · 0.45
iter_mutMethod · 0.45

Tested by

no test coverage detected