Skip to content

Commit

Permalink
expose instruction count directly:
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-finch-tezos authored and johnyob committed Oct 27, 2023
1 parent baddb1c commit d7969f8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion boa_engine/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub struct Context<'host> {

/// Number of instructions remaining before a forced exit
#[cfg(feature = "fuzz")]
pub(crate) instructions_remaining: usize,
pub instructions_remaining: usize,

pub(crate) vm: Vm,

Expand Down Expand Up @@ -519,6 +519,18 @@ impl<'host> Context<'host> {
pub const fn instructions_remaining(&self) -> u64 {
self.instructions_remaining
}

/// Create a new Realm with the default global bindings.
pub fn create_realm(&mut self) -> JsResult<Realm> {
let realm = Realm::create(&*self.host_hooks, &self.root_shape);

let old_realm = self.enter_realm(realm);

builtins::set_default_global_bindings(self)?;

Ok(self.enter_realm(old_realm))
}

/// Get the [`RootShape`].
#[inline]
#[must_use]
Expand Down

0 comments on commit d7969f8

Please sign in to comment.