flowgraph.c mark_cold
(blocks: &mut [Block])
| 2100 | |
| 2101 | /// flowgraph.c mark_cold |
| 2102 | fn 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 |
| 2143 | fn push_cold_blocks_to_end(blocks: &mut Vec<Block>) { |
no test coverage detected