(instructions: &[Instruction], index: usize)
| 1401 | local_reads(instruction) |
| 1402 | .into_iter() |
| 1403 | .chain(local_writes(instruction)) |
| 1404 | }) |
| 1405 | .map(|local| local.index + local.width) |
| 1406 | .max() |
| 1407 | .unwrap_or(0) |
| 1408 | } |
| 1409 | |
| 1410 | fn protected_instruction_indices( |
| 1411 | instructions: &[Instruction], |
| 1412 | exception_table: &[ExceptionTableEntry], |
| 1413 | ) -> BTreeSet<usize> { |
| 1414 | let mut protected = BTreeSet::from([0usize]); |
| 1415 | for (index, instruction) in instructions.iter().enumerate() { |
| 1416 | visit_branch_targets(index, instruction, |target| { |
| 1417 | if target >= 0 { |
| 1418 | protected.insert(target as usize); |
| 1419 | } |
| 1420 | }); |
| 1421 | } |
| 1422 | for entry in exception_table { |
| 1423 | protected.insert(usize::from(entry.range_pc.start)); |
| 1424 | if usize::from(entry.range_pc.end) < instructions.len() { |
| 1425 | protected.insert(usize::from(entry.range_pc.end)); |
| 1426 | } |
| 1427 | protected.insert(usize::from(entry.handler_pc)); |
| 1428 | } |
| 1429 | protected |
| 1430 | } |
| 1431 | |
| 1432 | fn compact_instructions( |
| 1433 | instructions: Vec<Instruction>, |
| 1434 | source_locations: Vec<BytecodeMetadata>, |
| 1435 | keep: &[bool], |
| 1436 | exception_table: &mut Vec<ExceptionTableEntry>, |
| 1437 | ) -> jvm::Result<LocatedInstructions> { |
no test coverage detected