fix: correct instruction index in calculate_size function

- Fixed incorrect get() index from total_size + 1 to proper instruction index
- Use enumerate() to get correct instruction index for prefetch optimization
- Prevents array bounds errors and ensures correct next instruction prefetch

Bug: Using total_size (byte count) as array index for instruction lookup
Solution: Use enumerate() iterator index for proper instruction access
This commit is contained in:
abc
2025-12-09 23:58:26 +08:00
parent aa0a452bb2
commit 7c5a8b0f50
+2 -2
View File
@@ -106,10 +106,10 @@ impl InstructionProcessor {
pub fn calculate_size(instructions: &[Instruction]) -> usize {
let mut total_size = 0;
for instr in instructions {
for (i, instr) in instructions.iter().enumerate() {
// 预取下一条指令
unsafe {
if let Some(next_instr) = instructions.get(total_size + 1) {
if let Some(next_instr) = instructions.get(i + 1) {
BranchOptimizer::prefetch_read_data(next_instr);
}
}