Skip to content

Commit

Permalink
make the NoInstructionsRemaining error variant uncatchable
Browse files Browse the repository at this point in the history
  • Loading branch information
addisoncrump committed Nov 6, 2022
1 parent 06c4807 commit a8a8f83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions boa_engine/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,9 @@ impl JsNativeError {
JsNativeErrorKind::Uri => (constructors.uri_error().prototype(), ErrorKind::Uri),
#[cfg(feature = "fuzz")]
JsNativeErrorKind::NoInstructionsRemain => {
// we can propagate out from try/catch since the catch block will also perform some
// operation
(constructors.error().prototype(), ErrorKind::Error)
unreachable!(
"The NoInstructionsRemain native error cannot be converted to an opaque type."
)
}
};

Expand Down
14 changes: 7 additions & 7 deletions boa_engine/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,6 @@ pub(crate) enum ReturnType {

impl Context {
fn execute_instruction(&mut self) -> JsResult<ShouldExit> {
#[cfg(feature = "fuzz")]
if self.insns_remaining == 0 {
return Err(JsError::from_native(JsNativeError::no_instructions_remain()));
} else {
self.insns_remaining -= 1;
}

let opcode: Opcode = {
let _timer = Profiler::global().start_event("Opcode retrieval", "vm");
let opcode = self.vm.frame().code.code[self.vm.frame().pc]
Expand Down Expand Up @@ -186,6 +179,13 @@ impl Context {
});

while self.vm.frame().pc < self.vm.frame().code.code.len() {
#[cfg(feature = "fuzz")]
if self.insns_remaining == 0 {
return Err(JsError::from_native(JsNativeError::no_instructions_remain()));
} else {
self.insns_remaining -= 1;
}

let result = if self.vm.trace {
let mut pc = self.vm.frame().pc;
let opcode: Opcode = self
Expand Down

0 comments on commit a8a8f83

Please sign in to comment.