diff --git a/boa_engine/src/vm/code_block.rs b/boa_engine/src/vm/code_block.rs index 85272b234fe..bdf921cf824 100644 --- a/boa_engine/src/vm/code_block.rs +++ b/boa_engine/src/vm/code_block.rs @@ -240,10 +240,10 @@ impl CodeBlock { } pub(crate) fn find_handler(&self, pc: u32) -> Option<&Handler> { - self.handlers + dbg!(self.handlers .iter() .rev() - .find(|&handler| handler.range.contains(&pc)) + .find(|&handler| handler.range.contains(&pc))) } } @@ -679,6 +679,25 @@ impl ToInternedString for CodeBlock { let mut pc = 0; let mut count = 0; while pc < self.bytecode.len() { + for (i, handler) in self.handlers.iter().enumerate().rev() { + if pc == handler.range.start as usize { + f.push_str(&format!( + "\n# Handler {i} start: handler: {}\n", + handler.handler + )); + } + + if pc == handler.range.end as usize { + f.push_str(&format!( + "# Handler {i} end: handler: {}\n\n", + handler.handler + )); + } + + if pc == handler.handler as usize { + f.push('\n'); + } + } let opcode: Opcode = self.bytecode[pc].into(); let opcode = opcode.as_str(); let previous_pc = pc;