Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions crates/context/interface/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use core::{
cell::{Ref, RefCell},
ops::Range,
};
use std::{boxed::Box, rc::Rc, vec::Vec};
use std::{rc::Rc, vec::Vec};

/// Non-empty, item-pooling Vec.
#[derive(Debug, Clone)]
pub struct FrameStack<T> {
stack: Vec<Box<T>>,
stack: Vec<T>,
index: Option<usize>,
}

Expand All @@ -20,10 +20,9 @@ impl<T> Default for FrameStack<T> {

impl<T> FrameStack<T> {
/// Creates a new, empty stack. It must be initialized with init before use.
#[inline]
pub fn new() -> Self {
Self {
stack: Vec::with_capacity(1025),
stack: Vec::with_capacity(4),
index: None,
}
}
Expand Down Expand Up @@ -102,19 +101,19 @@ impl<T> FrameStack<T> {
/// A potentially initialized frame. Used when initializing a new frame in the main loop.
#[allow(missing_debug_implementations)]
pub struct OutFrame<'a, T> {
ptr: *mut Box<T>,
ptr: *mut T,
init: bool,
lt: core::marker::PhantomData<&'a mut T>,
}

impl<'a, T> OutFrame<'a, T> {
/// Creates a new initialized `OutFrame` from a mutable reference to a type `T`.
pub fn new_init(slot: &'a mut Box<T>) -> Self {
pub fn new_init(slot: &'a mut T) -> Self {
unsafe { Self::new_maybe_uninit(slot, true) }
}

/// Creates a new uninitialized `OutFrame` from a mutable reference to a `MaybeUninit<T>`.
pub fn new_uninit(slot: &'a mut core::mem::MaybeUninit<Box<T>>) -> Self {
pub fn new_uninit(slot: &'a mut core::mem::MaybeUninit<T>) -> Self {
unsafe { Self::new_maybe_uninit(slot.as_mut_ptr(), false) }
}

Expand All @@ -125,7 +124,7 @@ impl<'a, T> OutFrame<'a, T> {
/// This method is unsafe because it assumes that the pointer is valid and points to a location
/// where a type `T` can be stored. It also assumes that the `init` flag correctly reflects whether
/// the type `T` has been initialized or not.
pub unsafe fn new_maybe_uninit(ptr: *mut Box<T>, init: bool) -> Self {
pub unsafe fn new_maybe_uninit(ptr: *mut T, init: bool) -> Self {
Self {
ptr,
init,
Expand All @@ -141,11 +140,12 @@ impl<'a, T> OutFrame<'a, T> {
unsafe { &mut *self.ptr }
}

#[inline(never)]
#[cold]
fn do_init(&mut self, f: impl FnOnce() -> T) {
unsafe {
self.init = true;
self.ptr.write(Box::new(f()));
self.ptr.write(f());
}
}

Expand Down
2 changes: 2 additions & 0 deletions crates/interpreter/src/interpreter/ext_bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ impl Deref for ExtBytecode {
}

impl Default for ExtBytecode {
#[inline]
fn default() -> Self {
Self::new(Bytecode::default())
}
}

impl ExtBytecode {
/// Create new extended bytecode and set the instruction pointer to the start of the bytecode.
#[inline]
pub fn new(base: Bytecode) -> Self {
let instruction_pointer = base.bytecode_ptr();
Self {
Expand Down
Loading