minor changes
This commit is contained in:
Generated
-2
@@ -460,7 +460,6 @@ dependencies = [
|
||||
"mimalloc",
|
||||
"rnix",
|
||||
"rustyline",
|
||||
"smallvec",
|
||||
"string-interner",
|
||||
"tempfile",
|
||||
"test-log",
|
||||
@@ -485,7 +484,6 @@ dependencies = [
|
||||
"fix-builtins",
|
||||
"fix-common",
|
||||
"fix-ir",
|
||||
"gc-arena",
|
||||
"hashbrown 0.16.1",
|
||||
"num_enum",
|
||||
"rnix",
|
||||
|
||||
@@ -14,6 +14,10 @@ members = [
|
||||
inherits = "release"
|
||||
debug = true
|
||||
|
||||
[profile.lto]
|
||||
inherits = "release"
|
||||
lto = true
|
||||
|
||||
[workspace.dependencies]
|
||||
bumpalo = { version = "3.20", features = [
|
||||
"allocator-api2",
|
||||
|
||||
@@ -4,7 +4,6 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
gc-arena = { workspace = true }
|
||||
hashbrown = { workspace = true }
|
||||
num_enum = { workspace = true }
|
||||
rnix = { workspace = true }
|
||||
|
||||
@@ -24,7 +24,7 @@ impl<T: Default + Copy, const N: usize> ArrayExt<N> for [T; N] {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RawStore: Sized {
|
||||
pub(crate) trait RawStore: Sized {
|
||||
fn to_val(self, value: &mut Value);
|
||||
fn from_val(value: &Value) -> Self;
|
||||
}
|
||||
|
||||
+29
-30
@@ -122,6 +122,7 @@ pub struct Vm<C: VmContext> {
|
||||
struct GcRoot<'gc> {
|
||||
stack: Vec<Value<'gc>>,
|
||||
call_stack: Vec<CallFrame<'gc>>,
|
||||
call_depth: usize,
|
||||
with_env: Option<Gc<'gc, WithEnv<'gc>>>,
|
||||
builtins: Value<'gc>,
|
||||
empty_list: Value<'gc>,
|
||||
@@ -143,16 +144,16 @@ fn init_builtins<'gc>(mc: &Mutation<'gc>, ctx: &mut impl VmContext) -> Value<'gc
|
||||
let consts = [
|
||||
(
|
||||
"__currentSystem",
|
||||
Value::new_gc(Gc::new(mc, NixString::new("x86_64-linux"))),
|
||||
Value::new_inline(ctx.intern_string("x86_64-linux")),
|
||||
),
|
||||
("__langVersion", Value::new_inline(6i32)),
|
||||
(
|
||||
"__nixVersion",
|
||||
Value::new_gc(Gc::new(mc, NixString::new("2.24.0"))),
|
||||
Value::new_inline(ctx.intern_string("2.24.0")),
|
||||
),
|
||||
(
|
||||
"__storeDir",
|
||||
Value::new_gc(Gc::new(mc, NixString::new("/nix/store"))),
|
||||
Value::new_inline(ctx.intern_string("/nix/store")),
|
||||
),
|
||||
(
|
||||
"__nixPath",
|
||||
@@ -190,6 +191,7 @@ impl<'gc> GcRoot<'gc> {
|
||||
GcRoot {
|
||||
stack: Vec::with_capacity(8192),
|
||||
call_stack: Vec::with_capacity(1024),
|
||||
call_depth: 0,
|
||||
with_env: None,
|
||||
builtins,
|
||||
empty_list: Value::new_gc(Gc::new(mc, List::default())),
|
||||
@@ -404,6 +406,21 @@ impl<'gc> GcRoot<'gc> {
|
||||
}
|
||||
}
|
||||
}};
|
||||
(SelectKeyData, $n:expr) => {{
|
||||
let mut keys = SmallVec::<[SelectKeyData; 4]>::with_capacity($n as usize);
|
||||
for _ in 0..$n {
|
||||
let tag = read!(u8);
|
||||
let Ok(ty) = AttrKeyType::try_from_primitive(tag)
|
||||
.map_err(|err| panic!("unknown key tag: {:#04x}", err.number));
|
||||
match ty {
|
||||
AttrKeyType::Static => {
|
||||
keys.push(SelectKeyData::Static(read!(StringId)))
|
||||
}
|
||||
AttrKeyType::Dynamic => keys.push(SelectKeyData::Dynamic),
|
||||
};
|
||||
}
|
||||
keys
|
||||
}};
|
||||
($type:ty) => {
|
||||
<$type>::from_le_bytes(read_array(ctx.bytecode(), pc))
|
||||
};
|
||||
@@ -436,12 +453,12 @@ impl<'gc> GcRoot<'gc> {
|
||||
ThunkState::Evaluated(v) => {
|
||||
self.replace_stack($depth, v.relax());
|
||||
}
|
||||
ThunkState::Apply { .. } => todo!("force apply"),
|
||||
ThunkState::Blackhole => {
|
||||
return Action::Done(Err(Error::eval_error(
|
||||
"infinite recursion encountered",
|
||||
)));
|
||||
}
|
||||
ThunkState::Apply { .. } => todo!("force apply"),
|
||||
}
|
||||
}
|
||||
}};
|
||||
@@ -583,6 +600,10 @@ impl<'gc> GcRoot<'gc> {
|
||||
Call => {
|
||||
// force func
|
||||
try_force!(0, inst_start_pc);
|
||||
if self.call_depth > 10000 {
|
||||
return Action::Done(Err(Error::eval_error("stack overflow; max-call-depth exceeded")))
|
||||
}
|
||||
self.call_depth += 1;
|
||||
let func = self.pop_stack();
|
||||
let arg = self.pop_stack();
|
||||
if let Some(closure) = func.as_gc::<Closure>() {
|
||||
@@ -649,19 +670,7 @@ impl<'gc> GcRoot<'gc> {
|
||||
let n = read!(u16) as usize;
|
||||
let _span_id = read!(u32);
|
||||
|
||||
let mut keys = SmallVec::<[SelectKeyData; 4]>::with_capacity(n);
|
||||
for _ in 0..n {
|
||||
let tag = read!(u8);
|
||||
let Ok(ty) = AttrKeyType::try_from_primitive(tag)
|
||||
.map_err(|err| panic!("unknown key tag: {:#04x}", err.number));
|
||||
match ty {
|
||||
AttrKeyType::Static => {
|
||||
keys.push(SelectKeyData::Static(read!(StringId)))
|
||||
}
|
||||
AttrKeyType::Dynamic => keys.push(SelectKeyData::Dynamic),
|
||||
};
|
||||
}
|
||||
|
||||
let keys = read!(SelectKeyData, n);
|
||||
let dyn_count = keys
|
||||
.iter()
|
||||
.filter(|k| matches!(k, SelectKeyData::Dynamic))
|
||||
@@ -736,19 +745,7 @@ impl<'gc> GcRoot<'gc> {
|
||||
let n = read!(u16) as usize;
|
||||
let _span_id = read!(u32);
|
||||
|
||||
let mut keys = SmallVec::<[SelectKeyData; 4]>::with_capacity(n);
|
||||
for _ in 0..n {
|
||||
let tag = read!(u8);
|
||||
let Ok(ty) = AttrKeyType::try_from_primitive(tag)
|
||||
.map_err(|err| panic!("unknown key tag: {:#04x}", err.number));
|
||||
match ty {
|
||||
AttrKeyType::Static => {
|
||||
keys.push(SelectKeyData::Static(read!(StringId)))
|
||||
}
|
||||
AttrKeyType::Dynamic => keys.push(SelectKeyData::Dynamic),
|
||||
};
|
||||
}
|
||||
|
||||
let keys = read!(SelectKeyData, n);
|
||||
let dyn_count = keys
|
||||
.iter()
|
||||
.filter(|k| matches!(k, SelectKeyData::Dynamic))
|
||||
@@ -1253,6 +1250,8 @@ impl<'gc> GcRoot<'gc> {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.call_depth -= 1;
|
||||
}
|
||||
self.current_env = Some(env);
|
||||
self.with_env = with_env;
|
||||
|
||||
+4
-3
@@ -22,13 +22,14 @@ mod private {
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
///
|
||||
/// 1. TAG must be unique among all implementors.
|
||||
/// 2. TAG must be within 1..=7
|
||||
pub(crate) unsafe trait Storable: private::Cealed {
|
||||
pub unsafe trait Storable: private::Cealed {
|
||||
const TAG: (bool, u8);
|
||||
}
|
||||
pub(crate) trait InlineStorable: Storable + RawStore {}
|
||||
pub(crate) trait GcStorable: Storable {}
|
||||
pub trait InlineStorable: Storable + RawStore {}
|
||||
pub trait GcStorable: Storable {}
|
||||
|
||||
macro_rules! define_value_types {
|
||||
(
|
||||
|
||||
@@ -23,7 +23,6 @@ miette = { version = "7.4", features = ["fancy"] }
|
||||
|
||||
# Data Structure
|
||||
hashbrown = { workspace = true }
|
||||
smallvec = { workspace = true }
|
||||
string-interner = { workspace = true }
|
||||
|
||||
# Memory Management
|
||||
|
||||
@@ -509,6 +509,9 @@ struct OwnedIr {
|
||||
}
|
||||
|
||||
impl OwnedIr {
|
||||
/// # Safety
|
||||
///
|
||||
/// `ir` must be allocated from `bump`.
|
||||
unsafe fn new(ir: RawIrRef<'_>, bump: Bump) -> Self {
|
||||
Self {
|
||||
_bump: bump,
|
||||
|
||||
Reference in New Issue
Block a user