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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user