rename PrimOpPhase
This commit is contained in:
@@ -2,7 +2,7 @@ use std::fmt::Write;
|
|||||||
|
|
||||||
use colored::Colorize as _;
|
use colored::Colorize as _;
|
||||||
|
|
||||||
use crate::{InstructionPtr, Op, OperandType, PrimOpPhase};
|
use crate::{InstructionPtr, Op, OperandType, Continuation};
|
||||||
|
|
||||||
pub trait DisassemblerContext {
|
pub trait DisassemblerContext {
|
||||||
fn resolve_string(&self, id: u32) -> &str;
|
fn resolve_string(&self, id: u32) -> &str;
|
||||||
@@ -294,8 +294,8 @@ impl<'a, Ctx: DisassemblerContext> Disassembler<'a, Ctx> {
|
|||||||
self.read_operand_data();
|
self.read_operand_data();
|
||||||
("Call", "arg=?".into())
|
("Call", "arg=?".into())
|
||||||
}
|
}
|
||||||
Op::DispatchPrimOp => {
|
Op::DispatchCont => {
|
||||||
let phase = PrimOpPhase::try_from(self.read_u8()).expect("invalid primop phase");
|
let phase = Continuation::try_from(self.read_u8()).expect("invalid primop phase");
|
||||||
("DispatchPrimOp", format!("phase={phase:?}"))
|
("DispatchPrimOp", format!("phase={phase:?}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+233
-232
@@ -31,7 +31,7 @@ pub enum Op {
|
|||||||
MakePatternClosure,
|
MakePatternClosure,
|
||||||
|
|
||||||
Call,
|
Call,
|
||||||
DispatchPrimOp,
|
DispatchCont,
|
||||||
|
|
||||||
MakeAttrs,
|
MakeAttrs,
|
||||||
MakeEmptyAttrs,
|
MakeEmptyAttrs,
|
||||||
@@ -133,128 +133,140 @@ pub enum OperandData {
|
|||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
|
||||||
pub enum PrimOpPhase {
|
pub enum Continuation {
|
||||||
Abort,
|
// primops
|
||||||
Add,
|
PAbort,
|
||||||
AddErrorContext,
|
PAdd,
|
||||||
|
PAddErrorContext,
|
||||||
|
|
||||||
All,
|
PAll,
|
||||||
AllCallPred,
|
PAllCallPred,
|
||||||
AllCheck,
|
PAllCheck,
|
||||||
|
|
||||||
Any,
|
PAny,
|
||||||
AnyCallPred,
|
PAnyCallPred,
|
||||||
AnyCheck,
|
PAnyCheck,
|
||||||
|
|
||||||
AppendContext,
|
PAppendContext,
|
||||||
AttrNames,
|
PAppendContextLoop,
|
||||||
AttrValues,
|
PAppendContextEntryForced,
|
||||||
BaseNameOf,
|
PAppendContextOutputsForced,
|
||||||
BitAnd,
|
PAppendContextOutputElementLoop,
|
||||||
BitOr,
|
PAppendContextOutputElementForced,
|
||||||
BitXor,
|
|
||||||
Break,
|
|
||||||
CatAttrs,
|
|
||||||
Ceil,
|
|
||||||
CompareVersions,
|
|
||||||
ConcatLists,
|
|
||||||
ConcatMap,
|
|
||||||
ConcatStringsSep,
|
|
||||||
ConvertHash,
|
|
||||||
|
|
||||||
DeepSeq,
|
PAttrNames,
|
||||||
DeepSeqPush,
|
PAttrValues,
|
||||||
DeepSeqLoop,
|
PBaseNameOf,
|
||||||
|
PBitAnd,
|
||||||
|
PBitOr,
|
||||||
|
PBitXor,
|
||||||
|
PBreak,
|
||||||
|
PCatAttrs,
|
||||||
|
PCeil,
|
||||||
|
PCompareVersions,
|
||||||
|
PConcatLists,
|
||||||
|
PConcatMap,
|
||||||
|
PConcatStringsSep,
|
||||||
|
PConvertHash,
|
||||||
|
|
||||||
Derivation,
|
PDeepSeq,
|
||||||
DerivationStrict,
|
PDeepSeqPush,
|
||||||
DirOf,
|
PDeepSeqLoop,
|
||||||
Div,
|
|
||||||
Elem,
|
|
||||||
ElemAt,
|
|
||||||
FetchGit,
|
|
||||||
FetchMercurial,
|
|
||||||
FetchTarball,
|
|
||||||
FetchTree,
|
|
||||||
FetchUrl,
|
|
||||||
|
|
||||||
FilterForceList,
|
PDerivation,
|
||||||
FilterCallPred,
|
PDerivationStrict,
|
||||||
FilterCheck,
|
PDirOf,
|
||||||
|
PDiv,
|
||||||
|
PElem,
|
||||||
|
PElemAt,
|
||||||
|
PFetchGit,
|
||||||
|
PFetchMercurial,
|
||||||
|
PFetchTarball,
|
||||||
|
PFetchTree,
|
||||||
|
PFetchUrl,
|
||||||
|
|
||||||
FilterSource,
|
PFilterForceList,
|
||||||
FindFile,
|
PFilterCallPred,
|
||||||
Floor,
|
PFilterCheck,
|
||||||
FoldlStrict,
|
|
||||||
FoldlStrictEmpty,
|
PFilterSource,
|
||||||
FoldlStrictCall1,
|
PFindFile,
|
||||||
FoldlStrictCall2,
|
PFloor,
|
||||||
FoldlStrictUpdate,
|
PFoldlStrict,
|
||||||
FromJSON,
|
PFoldlStrictEmpty,
|
||||||
FromTOML,
|
PFoldlStrictCall1,
|
||||||
FunctionArgs,
|
PFoldlStrictCall2,
|
||||||
GenList,
|
PFoldlStrictUpdate,
|
||||||
GenericClosure,
|
PFromJSON,
|
||||||
GetAttr,
|
PFromTOML,
|
||||||
GetContext,
|
PFunctionArgs,
|
||||||
GetEnv,
|
PGenList,
|
||||||
GroupBy,
|
PGenericClosure,
|
||||||
HasAttr,
|
PGetAttr,
|
||||||
HasContext,
|
PGetContext,
|
||||||
HashFile,
|
PGetEnv,
|
||||||
HashString,
|
PGroupBy,
|
||||||
Head,
|
PHasAttr,
|
||||||
Import,
|
PHasContext,
|
||||||
IntersectAttrs,
|
PHashFile,
|
||||||
IsAttrs,
|
PHashString,
|
||||||
IsBool,
|
PHead,
|
||||||
IsFloat,
|
|
||||||
IsFunction,
|
PImport,
|
||||||
IsInt,
|
PImportFinalize,
|
||||||
IsList,
|
PScopedImport,
|
||||||
IsNull,
|
PScopedImportFinalize,
|
||||||
IsPath,
|
|
||||||
IsString,
|
PIntersectAttrs,
|
||||||
Length,
|
PIsAttrs,
|
||||||
LessThan,
|
PIsBool,
|
||||||
ListToAttrs,
|
PIsFloat,
|
||||||
Map,
|
PIsFunction,
|
||||||
MapAttrs,
|
PIsInt,
|
||||||
Match,
|
PIsList,
|
||||||
Mul,
|
PIsNull,
|
||||||
ParseDrvName,
|
PIsPath,
|
||||||
Partition,
|
PIsString,
|
||||||
Path,
|
PLength,
|
||||||
PathExists,
|
PLessThan,
|
||||||
Placeholder,
|
PListToAttrs,
|
||||||
ReadDir,
|
PMap,
|
||||||
ReadFile,
|
PMapAttrs,
|
||||||
ReadFileType,
|
PMatch,
|
||||||
RemoveAttrs,
|
PMul,
|
||||||
ReplaceStrings,
|
PParseDrvName,
|
||||||
ScopedImport,
|
PPartition,
|
||||||
Seq,
|
PPath,
|
||||||
Sort,
|
PPathExists,
|
||||||
Split,
|
PPlaceholder,
|
||||||
SplitVersion,
|
PReadDir,
|
||||||
StorePath,
|
PReadFile,
|
||||||
StringLength,
|
PReadFileType,
|
||||||
Sub,
|
PRemoveAttrs,
|
||||||
Substring,
|
PReplaceStrings,
|
||||||
Tail,
|
PSeq,
|
||||||
Throw,
|
PSort,
|
||||||
ToFile,
|
PSplit,
|
||||||
ToJSON,
|
PSplitVersion,
|
||||||
ToPath,
|
PStorePath,
|
||||||
ToString,
|
PStringLength,
|
||||||
ToXML,
|
PSub,
|
||||||
Trace,
|
PSubstring,
|
||||||
TryEval,
|
PTail,
|
||||||
TypeOf,
|
PThrow,
|
||||||
UnsafeDiscardStringContext,
|
PToFile,
|
||||||
UnsafeGetAttrPos,
|
PToJSON,
|
||||||
Warn,
|
PToPath,
|
||||||
ZipAttrsWith,
|
PToString,
|
||||||
|
PToXML,
|
||||||
|
PTrace,
|
||||||
|
PTryEval,
|
||||||
|
PTypeOf,
|
||||||
|
PUnsafeDiscardStringContext,
|
||||||
|
PUnsafeGetAttrPos,
|
||||||
|
PWarn,
|
||||||
|
PZipAttrsWith,
|
||||||
|
PUnsafeDiscardOutputDependency,
|
||||||
|
|
||||||
ForceResultShallow,
|
ForceResultShallow,
|
||||||
ForceResultShallowPush,
|
ForceResultShallowPush,
|
||||||
@@ -268,21 +280,10 @@ pub enum PrimOpPhase {
|
|||||||
CallFunctor1,
|
CallFunctor1,
|
||||||
CallFunctor2,
|
CallFunctor2,
|
||||||
|
|
||||||
ImportFinalize,
|
|
||||||
ScopedImportFinalize,
|
|
||||||
|
|
||||||
AppendContextLoop,
|
|
||||||
AppendContextEntryForced,
|
|
||||||
AppendContextOutputsForced,
|
|
||||||
AppendContextOutputElementLoop,
|
|
||||||
AppendContextOutputElementForced,
|
|
||||||
|
|
||||||
UnsafeDiscardOutputDependency,
|
|
||||||
|
|
||||||
Illegal,
|
Illegal,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<u8> for PrimOpPhase {
|
impl TryFrom<u8> for Continuation {
|
||||||
type Error = u8;
|
type Error = u8;
|
||||||
|
|
||||||
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
||||||
@@ -294,113 +295,113 @@ impl TryFrom<u8> for PrimOpPhase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrimOpPhase {
|
impl Continuation {
|
||||||
pub fn entry_for_builtin(id: BuiltinId) -> Self {
|
pub fn entry_for_builtin(id: BuiltinId) -> Self {
|
||||||
use BuiltinId::*;
|
use BuiltinId::*;
|
||||||
match id {
|
match id {
|
||||||
Abort => Self::Abort,
|
Abort => Self::PAbort,
|
||||||
Add => Self::Add,
|
Add => Self::PAdd,
|
||||||
AddErrorContext => Self::AddErrorContext,
|
AddErrorContext => Self::PAddErrorContext,
|
||||||
All => Self::All,
|
All => Self::PAll,
|
||||||
Any => Self::Any,
|
Any => Self::PAny,
|
||||||
AppendContext => Self::AppendContext,
|
AppendContext => Self::PAppendContext,
|
||||||
AttrNames => Self::AttrNames,
|
AttrNames => Self::PAttrNames,
|
||||||
AttrValues => Self::AttrValues,
|
AttrValues => Self::PAttrValues,
|
||||||
BaseNameOf => Self::BaseNameOf,
|
BaseNameOf => Self::PBaseNameOf,
|
||||||
BitAnd => Self::BitAnd,
|
BitAnd => Self::PBitAnd,
|
||||||
BitOr => Self::BitOr,
|
BitOr => Self::PBitOr,
|
||||||
BitXor => Self::BitXor,
|
BitXor => Self::PBitXor,
|
||||||
Break => Self::Break,
|
Break => Self::PBreak,
|
||||||
CatAttrs => Self::CatAttrs,
|
CatAttrs => Self::PCatAttrs,
|
||||||
Ceil => Self::Ceil,
|
Ceil => Self::PCeil,
|
||||||
CompareVersions => Self::CompareVersions,
|
CompareVersions => Self::PCompareVersions,
|
||||||
ConcatLists => Self::ConcatLists,
|
ConcatLists => Self::PConcatLists,
|
||||||
ConcatMap => Self::ConcatMap,
|
ConcatMap => Self::PConcatMap,
|
||||||
ConcatStringsSep => Self::ConcatStringsSep,
|
ConcatStringsSep => Self::PConcatStringsSep,
|
||||||
ConvertHash => Self::ConvertHash,
|
ConvertHash => Self::PConvertHash,
|
||||||
DeepSeq => Self::DeepSeq,
|
DeepSeq => Self::PDeepSeq,
|
||||||
Derivation => Self::Derivation,
|
Derivation => Self::PDerivation,
|
||||||
DerivationStrict => Self::DerivationStrict,
|
DerivationStrict => Self::PDerivationStrict,
|
||||||
DirOf => Self::DirOf,
|
DirOf => Self::PDirOf,
|
||||||
Div => Self::Div,
|
Div => Self::PDiv,
|
||||||
Elem => Self::Elem,
|
Elem => Self::PElem,
|
||||||
ElemAt => Self::ElemAt,
|
ElemAt => Self::PElemAt,
|
||||||
FetchGit => Self::FetchGit,
|
FetchGit => Self::PFetchGit,
|
||||||
FetchMercurial => Self::FetchMercurial,
|
FetchMercurial => Self::PFetchMercurial,
|
||||||
FetchTarball => Self::FetchTarball,
|
FetchTarball => Self::PFetchTarball,
|
||||||
FetchTree => Self::FetchTree,
|
FetchTree => Self::PFetchTree,
|
||||||
FetchUrl => Self::FetchUrl,
|
FetchUrl => Self::PFetchUrl,
|
||||||
Filter => Self::FilterForceList,
|
Filter => Self::PFilterForceList,
|
||||||
FilterSource => Self::FilterSource,
|
FilterSource => Self::PFilterSource,
|
||||||
FindFile => Self::FindFile,
|
FindFile => Self::PFindFile,
|
||||||
Floor => Self::Floor,
|
Floor => Self::PFloor,
|
||||||
FoldlStrict => Self::FoldlStrict,
|
FoldlStrict => Self::PFoldlStrict,
|
||||||
FromJSON => Self::FromJSON,
|
FromJSON => Self::PFromJSON,
|
||||||
FromTOML => Self::FromTOML,
|
FromTOML => Self::PFromTOML,
|
||||||
FunctionArgs => Self::FunctionArgs,
|
FunctionArgs => Self::PFunctionArgs,
|
||||||
GenList => Self::GenList,
|
GenList => Self::PGenList,
|
||||||
GenericClosure => Self::GenericClosure,
|
GenericClosure => Self::PGenericClosure,
|
||||||
GetAttr => Self::GetAttr,
|
GetAttr => Self::PGetAttr,
|
||||||
GetContext => Self::GetContext,
|
GetContext => Self::PGetContext,
|
||||||
GetEnv => Self::GetEnv,
|
GetEnv => Self::PGetEnv,
|
||||||
GroupBy => Self::GroupBy,
|
GroupBy => Self::PGroupBy,
|
||||||
HasAttr => Self::HasAttr,
|
HasAttr => Self::PHasAttr,
|
||||||
HasContext => Self::HasContext,
|
HasContext => Self::PHasContext,
|
||||||
HashFile => Self::HashFile,
|
HashFile => Self::PHashFile,
|
||||||
HashString => Self::HashString,
|
HashString => Self::PHashString,
|
||||||
Head => Self::Head,
|
Head => Self::PHead,
|
||||||
Import => Self::Import,
|
Import => Self::PImport,
|
||||||
IntersectAttrs => Self::IntersectAttrs,
|
IntersectAttrs => Self::PIntersectAttrs,
|
||||||
IsAttrs => Self::IsAttrs,
|
IsAttrs => Self::PIsAttrs,
|
||||||
IsBool => Self::IsBool,
|
IsBool => Self::PIsBool,
|
||||||
IsFloat => Self::IsFloat,
|
IsFloat => Self::PIsFloat,
|
||||||
IsFunction => Self::IsFunction,
|
IsFunction => Self::PIsFunction,
|
||||||
IsInt => Self::IsInt,
|
IsInt => Self::PIsInt,
|
||||||
IsList => Self::IsList,
|
IsList => Self::PIsList,
|
||||||
IsNull => Self::IsNull,
|
IsNull => Self::PIsNull,
|
||||||
IsPath => Self::IsPath,
|
IsPath => Self::PIsPath,
|
||||||
IsString => Self::IsString,
|
IsString => Self::PIsString,
|
||||||
Length => Self::Length,
|
Length => Self::PLength,
|
||||||
LessThan => Self::LessThan,
|
LessThan => Self::PLessThan,
|
||||||
ListToAttrs => Self::ListToAttrs,
|
ListToAttrs => Self::PListToAttrs,
|
||||||
Map => Self::Map,
|
Map => Self::PMap,
|
||||||
MapAttrs => Self::MapAttrs,
|
MapAttrs => Self::PMapAttrs,
|
||||||
Match => Self::Match,
|
Match => Self::PMatch,
|
||||||
Mul => Self::Mul,
|
Mul => Self::PMul,
|
||||||
ParseDrvName => Self::ParseDrvName,
|
ParseDrvName => Self::PParseDrvName,
|
||||||
Partition => Self::Partition,
|
Partition => Self::PPartition,
|
||||||
Path => Self::Path,
|
Path => Self::PPath,
|
||||||
PathExists => Self::PathExists,
|
PathExists => Self::PPathExists,
|
||||||
Placeholder => Self::Placeholder,
|
Placeholder => Self::PPlaceholder,
|
||||||
ReadDir => Self::ReadDir,
|
ReadDir => Self::PReadDir,
|
||||||
ReadFile => Self::ReadFile,
|
ReadFile => Self::PReadFile,
|
||||||
ReadFileType => Self::ReadFileType,
|
ReadFileType => Self::PReadFileType,
|
||||||
RemoveAttrs => Self::RemoveAttrs,
|
RemoveAttrs => Self::PRemoveAttrs,
|
||||||
ReplaceStrings => Self::ReplaceStrings,
|
ReplaceStrings => Self::PReplaceStrings,
|
||||||
ScopedImport => Self::ScopedImport,
|
ScopedImport => Self::PScopedImport,
|
||||||
Seq => Self::Seq,
|
Seq => Self::PSeq,
|
||||||
Sort => Self::Sort,
|
Sort => Self::PSort,
|
||||||
Split => Self::Split,
|
Split => Self::PSplit,
|
||||||
SplitVersion => Self::SplitVersion,
|
SplitVersion => Self::PSplitVersion,
|
||||||
StorePath => Self::StorePath,
|
StorePath => Self::PStorePath,
|
||||||
StringLength => Self::StringLength,
|
StringLength => Self::PStringLength,
|
||||||
Sub => Self::Sub,
|
Sub => Self::PSub,
|
||||||
Substring => Self::Substring,
|
Substring => Self::PSubstring,
|
||||||
Tail => Self::Tail,
|
Tail => Self::PTail,
|
||||||
Throw => Self::Throw,
|
Throw => Self::PThrow,
|
||||||
ToFile => Self::ToFile,
|
ToFile => Self::PToFile,
|
||||||
ToJSON => Self::ToJSON,
|
ToJSON => Self::PToJSON,
|
||||||
ToPath => Self::ToPath,
|
ToPath => Self::PToPath,
|
||||||
ToString => Self::ToString,
|
ToString => Self::PToString,
|
||||||
ToXML => Self::ToXML,
|
ToXML => Self::PToXML,
|
||||||
Trace => Self::Trace,
|
Trace => Self::PTrace,
|
||||||
TryEval => Self::TryEval,
|
TryEval => Self::PTryEval,
|
||||||
TypeOf => Self::TypeOf,
|
TypeOf => Self::PTypeOf,
|
||||||
UnsafeDiscardStringContext => Self::UnsafeDiscardStringContext,
|
UnsafeDiscardStringContext => Self::PUnsafeDiscardStringContext,
|
||||||
UnsafeDiscardOutputDependency => Self::UnsafeDiscardOutputDependency,
|
UnsafeDiscardOutputDependency => Self::PUnsafeDiscardOutputDependency,
|
||||||
UnsafeGetAttrPos => Self::UnsafeGetAttrPos,
|
UnsafeGetAttrPos => Self::PUnsafeGetAttrPos,
|
||||||
Warn => Self::Warn,
|
Warn => Self::PWarn,
|
||||||
ZipAttrsWith => Self::ZipAttrsWith,
|
ZipAttrsWith => Self::PZipAttrsWith,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use fix_bytecode::{Const, InstructionPtr, Op, PrimOpPhase};
|
use fix_bytecode::{Const, InstructionPtr, Op, Continuation};
|
||||||
use fix_error::{Error, Result, Source};
|
use fix_error::{Error, Result, Source};
|
||||||
use fix_lang::{StringId, Symbol};
|
use fix_lang::{StringId, Symbol};
|
||||||
use fix_runtime::{StaticValue, VmCode, VmRuntimeCtx};
|
use fix_runtime::{StaticValue, VmCode, VmRuntimeCtx};
|
||||||
@@ -25,9 +25,9 @@ pub struct CodeState {
|
|||||||
impl CodeState {
|
impl CodeState {
|
||||||
pub fn new(strings: &mut DefaultStringInterner) -> Self {
|
pub fn new(strings: &mut DefaultStringInterner) -> Self {
|
||||||
let global_env = crate::ir::new_global_env(strings);
|
let global_env = crate::ir::new_global_env(strings);
|
||||||
let mut bytecode = Vec::with_capacity(PrimOpPhase::Illegal as usize * 2);
|
let mut bytecode = Vec::with_capacity(Continuation::Illegal as usize * 2);
|
||||||
for phase in 0..=PrimOpPhase::Illegal as u8 {
|
for phase in 0..=Continuation::Illegal as u8 {
|
||||||
bytecode.push(Op::DispatchPrimOp as u8);
|
bytecode.push(Op::DispatchCont as u8);
|
||||||
bytecode.push(phase);
|
bytecode.push(phase);
|
||||||
}
|
}
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use fix_bytecode::{Const, InstructionPtr, Op, OperandType, PrimOpPhase};
|
use fix_bytecode::{Const, InstructionPtr, Op, OperandType, Continuation};
|
||||||
use fix_lang::{BUILTINS, StringId};
|
use fix_lang::{BUILTINS, StringId};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use rnix::TextRange;
|
use rnix::TextRange;
|
||||||
@@ -80,7 +80,7 @@ impl<'a, Ctx: BytecodeContext> BytecodeEmitter<'a, Ctx> {
|
|||||||
InlineOperand::Const(Const::PrimOp {
|
InlineOperand::Const(Const::PrimOp {
|
||||||
id,
|
id,
|
||||||
arity,
|
arity,
|
||||||
dispatch_ip: PrimOpPhase::entry_for_builtin(id).ip(),
|
dispatch_ip: Continuation::entry_for_builtin(id).ip(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
BuiltinConst(id) => InlineOperand::BuiltinConst(id),
|
BuiltinConst(id) => InlineOperand::BuiltinConst(id),
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ tail_fn!(op_make_closure, (reader, mc));
|
|||||||
tail_fn!(op_make_pattern_closure, (reader, mc));
|
tail_fn!(op_make_pattern_closure, (reader, mc));
|
||||||
|
|
||||||
tail_fn!(op_call, (ctx, reader, mc));
|
tail_fn!(op_call, (ctx, reader, mc));
|
||||||
tail_fn!(op_dispatch_primop, (ctx, reader, mc));
|
tail_fn!(op_dispatch_cont, (ctx, reader, mc));
|
||||||
tail_fn!(op_return, (ctx, reader, mc));
|
tail_fn!(op_return, (ctx, reader, mc));
|
||||||
|
|
||||||
tail_fn!(op_make_attrs, (ctx, reader, mc));
|
tail_fn!(op_make_attrs, (ctx, reader, mc));
|
||||||
@@ -235,7 +235,7 @@ table! {
|
|||||||
MakePatternClosure => op_make_pattern_closure,
|
MakePatternClosure => op_make_pattern_closure,
|
||||||
|
|
||||||
Call => op_call,
|
Call => op_call,
|
||||||
DispatchPrimOp => op_dispatch_primop,
|
DispatchCont => op_dispatch_cont,
|
||||||
Return => op_return,
|
Return => op_return,
|
||||||
|
|
||||||
MakeAttrs => op_make_attrs,
|
MakeAttrs => op_make_attrs,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use fix_bytecode::PrimOpPhase;
|
use fix_bytecode::Continuation;
|
||||||
use fix_error::Error;
|
use fix_error::Error;
|
||||||
use fix_runtime::{resolve_operand, *};
|
use fix_runtime::{resolve_operand, *};
|
||||||
use gc_arena::{Gc, Mutation, RefLock};
|
use gc_arena::{Gc, Mutation, RefLock};
|
||||||
@@ -31,7 +31,7 @@ pub(crate) fn call<'gc, M: Machine<'gc>>(
|
|||||||
thunk: None,
|
thunk: None,
|
||||||
env: m.env(),
|
env: m.env(),
|
||||||
});
|
});
|
||||||
reader.set_pc(PrimOpPhase::CallPattern.ip() as usize);
|
reader.set_pc(Continuation::CallPattern.ip() as usize);
|
||||||
return Step::Continue(());
|
return Step::Continue(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ pub(crate) fn call<'gc, M: Machine<'gc>>(
|
|||||||
m.push(arg);
|
m.push(arg);
|
||||||
m.push(func.relax());
|
m.push(func.relax());
|
||||||
m.push(functor);
|
m.push(functor);
|
||||||
reader.set_pc(PrimOpPhase::CallFunctor1.ip() as usize);
|
reader.set_pc(Continuation::CallFunctor1.ip() as usize);
|
||||||
return Step::Continue(());
|
return Step::Continue(());
|
||||||
} else {
|
} else {
|
||||||
return m.finish_err(Error::eval_error(format!(
|
return m.finish_err(Error::eval_error(format!(
|
||||||
@@ -142,19 +142,19 @@ pub(crate) fn op_return<'gc, M: Machine<'gc>>(
|
|||||||
ForceMode::AsIs => return m.finish_ok(ctx.convert_value(val.relax())),
|
ForceMode::AsIs => return m.finish_ok(ctx.convert_value(val.relax())),
|
||||||
ForceMode::Shallow => {
|
ForceMode::Shallow => {
|
||||||
m.push(val.relax());
|
m.push(val.relax());
|
||||||
reader.set_pc(PrimOpPhase::ForceResultShallow.ip() as usize);
|
reader.set_pc(Continuation::ForceResultShallow.ip() as usize);
|
||||||
return Step::Continue(());
|
return Step::Continue(());
|
||||||
}
|
}
|
||||||
ForceMode::Deep => {
|
ForceMode::Deep => {
|
||||||
m.push(val.relax());
|
m.push(val.relax());
|
||||||
m.push(val.relax());
|
m.push(val.relax());
|
||||||
m.push_call_frame(CallFrame {
|
m.push_call_frame(CallFrame {
|
||||||
pc: PrimOpPhase::ForceResultDeepFinish.ip() as usize,
|
pc: Continuation::ForceResultDeepFinish.ip() as usize,
|
||||||
thunk: None,
|
thunk: None,
|
||||||
env: m.env(),
|
env: m.env(),
|
||||||
});
|
});
|
||||||
m.inc_call_depth();
|
m.inc_call_depth();
|
||||||
reader.set_pc(PrimOpPhase::DeepSeq.ip() as usize);
|
reader.set_pc(Continuation::PDeepSeq.ip() as usize);
|
||||||
return Step::Continue(());
|
return Step::Continue(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,11 +171,11 @@ pub(crate) fn op_return<'gc, M: Machine<'gc>>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn op_dispatch_primop<'gc, M: Machine<'gc>>(
|
pub(crate) fn op_dispatch_cont<'gc, M: Machine<'gc>>(
|
||||||
m: &mut M,
|
m: &mut M,
|
||||||
ctx: &mut impl VmRuntimeCtx,
|
ctx: &mut impl VmRuntimeCtx,
|
||||||
reader: &mut BytecodeReader<'_>,
|
reader: &mut BytecodeReader<'_>,
|
||||||
mc: &Mutation<'gc>,
|
mc: &Mutation<'gc>,
|
||||||
) -> Step {
|
) -> Step {
|
||||||
crate::primops::dispatch_primop(m, ctx, reader, mc)
|
crate::primops::dispatch_cont(m, ctx, reader, mc)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use fix_bytecode::PrimOpPhase;
|
use fix_bytecode::Continuation;
|
||||||
use fix_error::Error;
|
use fix_error::Error;
|
||||||
use fix_lang::{BUILTINS, BuiltinId, StringId};
|
use fix_lang::{BUILTINS, BuiltinId, StringId};
|
||||||
use fix_runtime::{
|
use fix_runtime::{
|
||||||
@@ -25,7 +25,7 @@ pub(crate) fn op_load_builtin<'gc, M: Machine<'gc>>(
|
|||||||
m.push(Value::new_inline(PrimOp {
|
m.push(Value::new_inline(PrimOp {
|
||||||
id,
|
id,
|
||||||
arity: BUILTINS[id as usize].1,
|
arity: BUILTINS[id as usize].1,
|
||||||
dispatch_ip: PrimOpPhase::entry_for_builtin(id).ip(),
|
dispatch_ip: Continuation::entry_for_builtin(id).ip(),
|
||||||
}));
|
}));
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use fix_bytecode::{InstructionPtr, PrimOpPhase};
|
use fix_bytecode::{InstructionPtr, Continuation};
|
||||||
use fix_error::{Error, Result, Source};
|
use fix_error::{Error, Result, Source};
|
||||||
use fix_lang::{BUILTINS, BuiltinId, StringId};
|
use fix_lang::{BUILTINS, BuiltinId, StringId};
|
||||||
use gc_arena::metrics::Pacing;
|
use gc_arena::metrics::Pacing;
|
||||||
@@ -60,7 +60,7 @@ fn init_builtins<'gc>(mc: &Mutation<'gc>, ctx: &mut impl VmRuntimeCtx) -> Value<
|
|||||||
let id = BuiltinId::try_from(idx as u8).expect("infallible");
|
let id = BuiltinId::try_from(idx as u8).expect("infallible");
|
||||||
let name = name.strip_prefix("__").unwrap_or(name);
|
let name = name.strip_prefix("__").unwrap_or(name);
|
||||||
let name = ctx.intern_string(name);
|
let name = ctx.intern_string(name);
|
||||||
let dispatch_ip = PrimOpPhase::entry_for_builtin(id).ip();
|
let dispatch_ip = Continuation::entry_for_builtin(id).ip();
|
||||||
entries.push((
|
entries.push((
|
||||||
name,
|
name,
|
||||||
Value::new_inline(PrimOp {
|
Value::new_inline(PrimOp {
|
||||||
@@ -476,6 +476,8 @@ impl<'gc> Vm<'gc> {
|
|||||||
let mut fuel = Self::DEFAULT_FUEL_AMOUNT;
|
let mut fuel = Self::DEFAULT_FUEL_AMOUNT;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
use crate::instructions::op_dispatch_cont;
|
||||||
|
|
||||||
if fuel == 0 {
|
if fuel == 0 {
|
||||||
return Action::Continue { pc: reader.pc() };
|
return Action::Continue { pc: reader.pc() };
|
||||||
}
|
}
|
||||||
@@ -502,7 +504,7 @@ impl<'gc> Vm<'gc> {
|
|||||||
MakePatternClosure => op_make_pattern_closure(self, &mut reader, mc),
|
MakePatternClosure => op_make_pattern_closure(self, &mut reader, mc),
|
||||||
|
|
||||||
Call => op_call(self, ctx, &mut reader, mc),
|
Call => op_call(self, ctx, &mut reader, mc),
|
||||||
DispatchPrimOp => op_dispatch_primop(self, ctx, &mut reader, mc),
|
DispatchCont => op_dispatch_cont(self, ctx, &mut reader, mc),
|
||||||
Return => op_return(self, ctx, &mut reader, mc),
|
Return => op_return(self, ctx, &mut reader, mc),
|
||||||
|
|
||||||
MakeAttrs => op_make_attrs(self, ctx, &mut reader, mc),
|
MakeAttrs => op_make_attrs(self, ctx, &mut reader, mc),
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
//! See `fix-runtime/src/string_context.rs` for the
|
//! See `fix-runtime/src/string_context.rs` for the
|
||||||
//! `StringContextElem` type.
|
//! `StringContextElem` type.
|
||||||
|
|
||||||
use fix_bytecode::PrimOpPhase;
|
use fix_bytecode::Continuation;
|
||||||
use fix_error::Error;
|
use fix_error::Error;
|
||||||
use fix_lang::StringId;
|
use fix_lang::StringId;
|
||||||
use fix_runtime::{
|
use fix_runtime::{
|
||||||
@@ -196,7 +196,7 @@ pub fn append_context<'gc, M: Machine<'gc>>(
|
|||||||
m.push(Value::new_inline(0i32));
|
m.push(Value::new_inline(0i32));
|
||||||
m.push(Value::new_gc(acc));
|
m.push(Value::new_gc(acc));
|
||||||
|
|
||||||
reader.set_pc(PrimOpPhase::AppendContextLoop.ip() as usize);
|
reader.set_pc(Continuation::PAppendContextLoop.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,9 +221,9 @@ pub fn append_context_loop<'gc, M: Machine<'gc>>(
|
|||||||
0,
|
0,
|
||||||
reader,
|
reader,
|
||||||
mc,
|
mc,
|
||||||
PrimOpPhase::AppendContextEntryForced.ip() as usize,
|
Continuation::PAppendContextEntryForced.ip() as usize,
|
||||||
)?;
|
)?;
|
||||||
reader.set_pc(PrimOpPhase::AppendContextEntryForced.ip() as usize);
|
reader.set_pc(Continuation::PAppendContextEntryForced.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,9 +296,9 @@ pub fn append_context_entry_forced<'gc, M: Machine<'gc>>(
|
|||||||
0,
|
0,
|
||||||
reader,
|
reader,
|
||||||
mc,
|
mc,
|
||||||
PrimOpPhase::AppendContextOutputsForced.ip() as usize,
|
Continuation::PAppendContextOutputsForced.ip() as usize,
|
||||||
)?;
|
)?;
|
||||||
reader.set_pc(PrimOpPhase::AppendContextOutputsForced.ip() as usize);
|
reader.set_pc(Continuation::PAppendContextOutputsForced.ip() as usize);
|
||||||
return Step::Continue(());
|
return Step::Continue(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +306,7 @@ pub fn append_context_entry_forced<'gc, M: Machine<'gc>>(
|
|||||||
#[allow(clippy::unwrap_used)]
|
#[allow(clippy::unwrap_used)]
|
||||||
let idx_back = m.peek(1).as_inline::<i32>().unwrap();
|
let idx_back = m.peek(1).as_inline::<i32>().unwrap();
|
||||||
m.replace(1, Value::new_inline(idx_back + 1));
|
m.replace(1, Value::new_inline(idx_back + 1));
|
||||||
reader.set_pc(PrimOpPhase::AppendContextLoop.ip() as usize);
|
reader.set_pc(Continuation::PAppendContextLoop.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,12 +327,12 @@ pub fn append_context_outputs_forced<'gc, M: Machine<'gc>>(
|
|||||||
#[allow(clippy::unwrap_used)]
|
#[allow(clippy::unwrap_used)]
|
||||||
let idx_back = m.peek(1).as_inline::<i32>().unwrap();
|
let idx_back = m.peek(1).as_inline::<i32>().unwrap();
|
||||||
m.replace(1, Value::new_inline(idx_back + 1));
|
m.replace(1, Value::new_inline(idx_back + 1));
|
||||||
reader.set_pc(PrimOpPhase::AppendContextLoop.ip() as usize);
|
reader.set_pc(Continuation::PAppendContextLoop.ip() as usize);
|
||||||
return Step::Continue(());
|
return Step::Continue(());
|
||||||
}
|
}
|
||||||
|
|
||||||
m.push(Value::new_inline(0i32));
|
m.push(Value::new_inline(0i32));
|
||||||
reader.set_pc(PrimOpPhase::AppendContextOutputElementLoop.ip() as usize);
|
reader.set_pc(Continuation::PAppendContextOutputElementLoop.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,7 +355,7 @@ pub fn append_context_output_element_loop<'gc, M: Machine<'gc>>(
|
|||||||
#[allow(clippy::unwrap_used)]
|
#[allow(clippy::unwrap_used)]
|
||||||
let idx_back = m.peek(1).as_inline::<i32>().unwrap();
|
let idx_back = m.peek(1).as_inline::<i32>().unwrap();
|
||||||
m.replace(1, Value::new_inline(idx_back + 1));
|
m.replace(1, Value::new_inline(idx_back + 1));
|
||||||
reader.set_pc(PrimOpPhase::AppendContextLoop.ip() as usize);
|
reader.set_pc(Continuation::PAppendContextLoop.ip() as usize);
|
||||||
return Step::Continue(());
|
return Step::Continue(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,9 +365,9 @@ pub fn append_context_output_element_loop<'gc, M: Machine<'gc>>(
|
|||||||
0,
|
0,
|
||||||
reader,
|
reader,
|
||||||
mc,
|
mc,
|
||||||
PrimOpPhase::AppendContextOutputElementForced.ip() as usize,
|
Continuation::PAppendContextOutputElementForced.ip() as usize,
|
||||||
)?;
|
)?;
|
||||||
reader.set_pc(PrimOpPhase::AppendContextOutputElementForced.ip() as usize);
|
reader.set_pc(Continuation::PAppendContextOutputElementForced.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,7 +412,7 @@ pub fn append_context_output_element_forced<'gc, M: Machine<'gc>>(
|
|||||||
#[allow(clippy::unwrap_used)]
|
#[allow(clippy::unwrap_used)]
|
||||||
let oidx = m.peek(0).as_inline::<i32>().unwrap();
|
let oidx = m.peek(0).as_inline::<i32>().unwrap();
|
||||||
m.replace(0, Value::new_inline(oidx + 1));
|
m.replace(0, Value::new_inline(oidx + 1));
|
||||||
reader.set_pc(PrimOpPhase::AppendContextOutputElementLoop.ip() as usize);
|
reader.set_pc(Continuation::PAppendContextOutputElementLoop.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use fix_bytecode::PrimOpPhase;
|
use fix_bytecode::Continuation;
|
||||||
use fix_error::Error;
|
use fix_error::Error;
|
||||||
use fix_runtime::{
|
use fix_runtime::{
|
||||||
AttrSet, BytecodeReader, Closure, Env, List, Machine, MachineExt, Step, StrictValue, Value,
|
AttrSet, BytecodeReader, Closure, Env, List, Machine, MachineExt, Step, StrictValue, Value,
|
||||||
@@ -78,7 +78,7 @@ pub fn deep_seq_force_top<'gc, M: Machine<'gc>>(
|
|||||||
m.push(Value::new_gc(seen));
|
m.push(Value::new_gc(seen));
|
||||||
m.push(Value::new_gc(worklist));
|
m.push(Value::new_gc(worklist));
|
||||||
m.push(Value::new_inline(count));
|
m.push(Value::new_inline(count));
|
||||||
reader.set_pc(PrimOpPhase::DeepSeqPush.ip() as usize);
|
reader.set_pc(Continuation::PDeepSeqPush.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,8 +106,8 @@ pub fn deep_seq_push<'gc, M: Machine<'gc>>(
|
|||||||
m.push(item);
|
m.push(item);
|
||||||
|
|
||||||
// force item at TOS, resume at DeepSeqLoop after force
|
// force item at TOS, resume at DeepSeqLoop after force
|
||||||
m.force_slot_to_pc(0, reader, mc, PrimOpPhase::DeepSeqLoop.ip() as usize)?;
|
m.force_slot_to_pc(0, reader, mc, Continuation::PDeepSeqLoop.ip() as usize)?;
|
||||||
reader.set_pc(PrimOpPhase::DeepSeqLoop.ip() as usize);
|
reader.set_pc(Continuation::PDeepSeqLoop.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ pub fn deep_seq_loop<'gc, M: Machine<'gc>>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.replace(0, Value::new_inline(counter + added as i32));
|
m.replace(0, Value::new_inline(counter + added as i32));
|
||||||
reader.set_pc(PrimOpPhase::DeepSeqPush.ip() as usize);
|
reader.set_pc(Continuation::PDeepSeqPush.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ pub fn force_result_shallow<'gc, M: Machine<'gc>>(
|
|||||||
|
|
||||||
m.push(Value::new_inline(0i32));
|
m.push(Value::new_inline(0i32));
|
||||||
m.push(Value::new_inline(count as i32));
|
m.push(Value::new_inline(count as i32));
|
||||||
reader.set_pc(PrimOpPhase::ForceResultShallowPush.ip() as usize);
|
reader.set_pc(Continuation::ForceResultShallowPush.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,9 +225,9 @@ pub fn force_result_shallow_push<'gc, M: Machine<'gc>>(
|
|||||||
0,
|
0,
|
||||||
reader,
|
reader,
|
||||||
mc,
|
mc,
|
||||||
PrimOpPhase::ForceResultShallowLoop.ip() as usize,
|
Continuation::ForceResultShallowLoop.ip() as usize,
|
||||||
)?;
|
)?;
|
||||||
reader.set_pc(PrimOpPhase::ForceResultShallowLoop.ip() as usize);
|
reader.set_pc(Continuation::ForceResultShallowLoop.ip() as usize);
|
||||||
}
|
}
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
@@ -238,7 +238,7 @@ pub fn force_result_shallow_loop<'gc, M: Machine<'gc>>(
|
|||||||
_mc: &Mutation<'gc>,
|
_mc: &Mutation<'gc>,
|
||||||
) -> Step {
|
) -> Step {
|
||||||
let _ = m.pop(); // forced child
|
let _ = m.pop(); // forced child
|
||||||
reader.set_pc(PrimOpPhase::ForceResultShallowPush.ip() as usize);
|
reader.set_pc(Continuation::ForceResultShallowPush.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +288,7 @@ pub fn call_functor_1<'gc, M: Machine<'gc>>(
|
|||||||
reader,
|
reader,
|
||||||
mc,
|
mc,
|
||||||
self_val,
|
self_val,
|
||||||
PrimOpPhase::CallFunctor2.ip() as usize,
|
Continuation::CallFunctor2.ip() as usize,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use fix_bytecode::PrimOpPhase;
|
use fix_bytecode::Continuation;
|
||||||
use fix_runtime::{
|
use fix_runtime::{
|
||||||
AttrSet, BytecodeReader, CallFrame, List, Machine, MachineExt, NixNum, Null, Path, Step,
|
AttrSet, BytecodeReader, CallFrame, List, Machine, MachineExt, NixNum, Null, Path, Step,
|
||||||
StrictValue, Value, VmRuntimeCtx, VmRuntimeCtxExt,
|
StrictValue, Value, VmRuntimeCtx, VmRuntimeCtxExt,
|
||||||
@@ -71,7 +71,7 @@ pub fn eq_step<'gc, M: Machine<'gc>>(
|
|||||||
.expect("non-empty rhs queue");
|
.expect("non-empty rhs queue");
|
||||||
m.push(lhs);
|
m.push(lhs);
|
||||||
m.push(rhs);
|
m.push(rhs);
|
||||||
reader.set_pc(PrimOpPhase::EqForce.ip() as usize);
|
reader.set_pc(Continuation::EqForce.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ pub fn eq_force<'gc, M: Machine<'gc>>(
|
|||||||
) -> Step {
|
) -> Step {
|
||||||
let (lhs, rhs) = m.force_and_retry::<(StrictValue, StrictValue)>(reader, mc)?;
|
let (lhs, rhs) = m.force_and_retry::<(StrictValue, StrictValue)>(reader, mc)?;
|
||||||
apply_pair(m, ctx, mc, lhs, rhs);
|
apply_pair(m, ctx, mc, lhs, rhs);
|
||||||
reader.set_pc(PrimOpPhase::EqStep.ip() as usize);
|
reader.set_pc(Continuation::EqStep.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ fn enter_eq_machine<'gc, M: Machine<'gc>>(
|
|||||||
m.push(Value::new_inline(true));
|
m.push(Value::new_inline(true));
|
||||||
m.push(Value::new_gc(List::new(mc, lhs_init)));
|
m.push(Value::new_gc(List::new(mc, lhs_init)));
|
||||||
m.push(Value::new_gc(List::new(mc, rhs_init)));
|
m.push(Value::new_gc(List::new(mc, rhs_init)));
|
||||||
reader.set_pc(PrimOpPhase::EqStep.ip() as usize);
|
reader.set_pc(Continuation::EqStep.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use fix_bytecode::PrimOpPhase;
|
use fix_bytecode::Continuation;
|
||||||
use fix_error::Error;
|
use fix_error::Error;
|
||||||
use fix_lang::StringId;
|
use fix_lang::StringId;
|
||||||
use fix_runtime::{
|
use fix_runtime::{
|
||||||
@@ -43,7 +43,7 @@ pub fn import<'gc, M: Machine<'gc>>(
|
|||||||
m.push(Value::new_inline(path_sid));
|
m.push(Value::new_inline(path_sid));
|
||||||
let env = m.env();
|
let env = m.env();
|
||||||
m.push_call_frame(CallFrame {
|
m.push_call_frame(CallFrame {
|
||||||
pc: PrimOpPhase::ImportFinalize.ip() as usize,
|
pc: Continuation::PImportFinalize.ip() as usize,
|
||||||
thunk: None,
|
thunk: None,
|
||||||
env,
|
env,
|
||||||
});
|
});
|
||||||
@@ -111,7 +111,7 @@ pub fn scoped_import<'gc, M: Machine<'gc>>(
|
|||||||
|
|
||||||
let env = m.env();
|
let env = m.env();
|
||||||
m.push_call_frame(CallFrame {
|
m.push_call_frame(CallFrame {
|
||||||
pc: PrimOpPhase::ScopedImportFinalize.ip() as usize,
|
pc: Continuation::PScopedImportFinalize.ip() as usize,
|
||||||
thunk: None,
|
thunk: None,
|
||||||
env,
|
env,
|
||||||
});
|
});
|
||||||
|
|||||||
+15
-15
@@ -1,4 +1,4 @@
|
|||||||
use fix_bytecode::PrimOpPhase;
|
use fix_bytecode::Continuation;
|
||||||
use fix_runtime::{BytecodeReader, List, Machine, MachineExt, NixType, Step, StrictValue, Value};
|
use fix_runtime::{BytecodeReader, List, Machine, MachineExt, NixType, Step, StrictValue, Value};
|
||||||
use gc_arena::Mutation;
|
use gc_arena::Mutation;
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ pub fn filter_force_list<'gc, M: Machine<'gc>>(
|
|||||||
// prepare stack layout: [ pred list idx acc ]
|
// prepare stack layout: [ pred list idx acc ]
|
||||||
m.push(Value::new_inline(0));
|
m.push(Value::new_inline(0));
|
||||||
m.push(Value::new_gc(List::new_gc(mc)));
|
m.push(Value::new_gc(List::new_gc(mc)));
|
||||||
reader.set_pc(PrimOpPhase::FilterCallPred.ip() as usize);
|
reader.set_pc(Continuation::PFilterCallPred.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ pub fn filter_call_pred<'gc, M: Machine<'gc>>(
|
|||||||
#[allow(clippy::unwrap_used)]
|
#[allow(clippy::unwrap_used)]
|
||||||
let elem = m.peek_forced(2).as_gc::<List>().unwrap().inner.borrow()[idx as usize];
|
let elem = m.peek_forced(2).as_gc::<List>().unwrap().inner.borrow()[idx as usize];
|
||||||
m.push(pred.relax());
|
m.push(pred.relax());
|
||||||
m.call(reader, mc, elem, PrimOpPhase::FilterCheck.ip() as usize)
|
m.call(reader, mc, elem, Continuation::PFilterCheck.ip() as usize)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn filter_check<'gc, M: Machine<'gc>>(
|
pub fn filter_check<'gc, M: Machine<'gc>>(
|
||||||
@@ -64,7 +64,7 @@ pub fn filter_check<'gc, M: Machine<'gc>>(
|
|||||||
return m.return_from_primop(acc, reader);
|
return m.return_from_primop(acc, reader);
|
||||||
}
|
}
|
||||||
m.replace(1, Value::new_inline(idx + 1));
|
m.replace(1, Value::new_inline(idx + 1));
|
||||||
reader.set_pc(PrimOpPhase::FilterCallPred.ip() as usize);
|
reader.set_pc(Continuation::PFilterCallPred.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ pub fn foldl_strict_entry<'gc, M: Machine<'gc>>(
|
|||||||
};
|
};
|
||||||
if list.inner.borrow().is_empty() {
|
if list.inner.borrow().is_empty() {
|
||||||
let _ = m.pop(); // list
|
let _ = m.pop(); // list
|
||||||
reader.set_pc(PrimOpPhase::FoldlStrictEmpty.ip() as usize);
|
reader.set_pc(Continuation::PFoldlStrictEmpty.ip() as usize);
|
||||||
return Step::Continue(());
|
return Step::Continue(());
|
||||||
}
|
}
|
||||||
let list_val = m.pop();
|
let list_val = m.pop();
|
||||||
@@ -96,7 +96,7 @@ pub fn foldl_strict_entry<'gc, M: Machine<'gc>>(
|
|||||||
m.push(list_val);
|
m.push(list_val);
|
||||||
m.push(Value::new_inline(0i32));
|
m.push(Value::new_inline(0i32));
|
||||||
m.push(nul_val);
|
m.push(nul_val);
|
||||||
reader.set_pc(PrimOpPhase::FoldlStrictCall1.ip() as usize);
|
reader.set_pc(Continuation::PFoldlStrictCall1.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ pub fn foldl_strict_call1<'gc, M: Machine<'gc>>(
|
|||||||
let op = m.peek_forced(3);
|
let op = m.peek_forced(3);
|
||||||
let acc = m.peek(0);
|
let acc = m.peek(0);
|
||||||
m.push(op.relax());
|
m.push(op.relax());
|
||||||
m.call(reader, mc, acc, PrimOpPhase::FoldlStrictCall2.ip() as usize)
|
m.call(reader, mc, acc, Continuation::PFoldlStrictCall2.ip() as usize)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn foldl_strict_call2<'gc, M: Machine<'gc>>(
|
pub fn foldl_strict_call2<'gc, M: Machine<'gc>>(
|
||||||
@@ -136,7 +136,7 @@ pub fn foldl_strict_call2<'gc, M: Machine<'gc>>(
|
|||||||
reader,
|
reader,
|
||||||
mc,
|
mc,
|
||||||
elem,
|
elem,
|
||||||
PrimOpPhase::FoldlStrictUpdate.ip() as usize,
|
Continuation::PFoldlStrictUpdate.ip() as usize,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ pub fn foldl_strict_update<'gc, M: Machine<'gc>>(
|
|||||||
return m.return_from_primop(acc, reader);
|
return m.return_from_primop(acc, reader);
|
||||||
}
|
}
|
||||||
m.replace(1, Value::new_inline(idx + 1));
|
m.replace(1, Value::new_inline(idx + 1));
|
||||||
reader.set_pc(PrimOpPhase::FoldlStrictCall1.ip() as usize);
|
reader.set_pc(Continuation::PFoldlStrictCall1.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ pub fn all_entry<'gc, M: Machine<'gc>>(
|
|||||||
}
|
}
|
||||||
// prepare stack layout: [ pred list idx ]
|
// prepare stack layout: [ pred list idx ]
|
||||||
m.push(Value::new_inline(0));
|
m.push(Value::new_inline(0));
|
||||||
reader.set_pc(PrimOpPhase::AllCallPred.ip() as usize);
|
reader.set_pc(Continuation::PAllCallPred.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ pub fn all_call_pred<'gc, M: Machine<'gc>>(
|
|||||||
#[allow(clippy::unwrap_used)]
|
#[allow(clippy::unwrap_used)]
|
||||||
let elem = m.peek_forced(1).as_gc::<List>().unwrap().inner.borrow()[idx as usize];
|
let elem = m.peek_forced(1).as_gc::<List>().unwrap().inner.borrow()[idx as usize];
|
||||||
m.push(pred.relax());
|
m.push(pred.relax());
|
||||||
m.call(reader, mc, elem, PrimOpPhase::AllCheck.ip() as usize)
|
m.call(reader, mc, elem, Continuation::PAllCheck.ip() as usize)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all_check<'gc, M: Machine<'gc>>(
|
pub fn all_check<'gc, M: Machine<'gc>>(
|
||||||
@@ -219,7 +219,7 @@ pub fn all_check<'gc, M: Machine<'gc>>(
|
|||||||
return m.return_from_primop(Value::new_inline(ret), reader);
|
return m.return_from_primop(Value::new_inline(ret), reader);
|
||||||
}
|
}
|
||||||
m.replace(0, Value::new_inline(idx + 1));
|
m.replace(0, Value::new_inline(idx + 1));
|
||||||
reader.set_pc(PrimOpPhase::AllCallPred.ip() as usize);
|
reader.set_pc(Continuation::PAllCallPred.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ pub fn any_entry<'gc, M: Machine<'gc>>(
|
|||||||
}
|
}
|
||||||
// prepare stack layout: [ pred list idx ]
|
// prepare stack layout: [ pred list idx ]
|
||||||
m.push(Value::new_inline(0));
|
m.push(Value::new_inline(0));
|
||||||
reader.set_pc(PrimOpPhase::AnyCallPred.ip() as usize);
|
reader.set_pc(Continuation::PAnyCallPred.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,7 +257,7 @@ pub fn any_call_pred<'gc, M: Machine<'gc>>(
|
|||||||
#[allow(clippy::unwrap_used)]
|
#[allow(clippy::unwrap_used)]
|
||||||
let elem = m.peek_forced(1).as_gc::<List>().unwrap().inner.borrow()[idx as usize];
|
let elem = m.peek_forced(1).as_gc::<List>().unwrap().inner.borrow()[idx as usize];
|
||||||
m.push(pred.relax());
|
m.push(pred.relax());
|
||||||
m.call(reader, mc, elem, PrimOpPhase::AnyCheck.ip() as usize)
|
m.call(reader, mc, elem, Continuation::PAnyCheck.ip() as usize)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn any_check<'gc, M: Machine<'gc>>(
|
pub fn any_check<'gc, M: Machine<'gc>>(
|
||||||
@@ -278,6 +278,6 @@ pub fn any_check<'gc, M: Machine<'gc>>(
|
|||||||
return m.return_from_primop(Value::new_inline(ret), reader);
|
return m.return_from_primop(Value::new_inline(ret), reader);
|
||||||
}
|
}
|
||||||
m.replace(0, Value::new_inline(idx + 1));
|
m.replace(0, Value::new_inline(idx + 1));
|
||||||
reader.set_pc(PrimOpPhase::AnyCallPred.ip() as usize);
|
reader.set_pc(Continuation::PAnyCallPred.ip() as usize);
|
||||||
Step::Continue(())
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|||||||
+45
-44
@@ -10,7 +10,7 @@ pub use context::*;
|
|||||||
pub use control::*;
|
pub use control::*;
|
||||||
pub use conv::*;
|
pub use conv::*;
|
||||||
pub use eq::*;
|
pub use eq::*;
|
||||||
use fix_bytecode::PrimOpPhase;
|
use fix_bytecode::Continuation;
|
||||||
use fix_error::Error;
|
use fix_error::Error;
|
||||||
use fix_runtime::{BytecodeReader, Machine, Step, VmRuntimeCtx};
|
use fix_runtime::{BytecodeReader, Machine, Step, VmRuntimeCtx};
|
||||||
use gc_arena::Mutation;
|
use gc_arena::Mutation;
|
||||||
@@ -19,42 +19,42 @@ pub use list::*;
|
|||||||
pub use path::*;
|
pub use path::*;
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
pub fn dispatch_primop<'gc, M: Machine<'gc>>(
|
pub fn dispatch_cont<'gc, M: Machine<'gc>>(
|
||||||
m: &mut M,
|
m: &mut M,
|
||||||
ctx: &mut impl VmRuntimeCtx,
|
ctx: &mut impl VmRuntimeCtx,
|
||||||
reader: &mut BytecodeReader<'_>,
|
reader: &mut BytecodeReader<'_>,
|
||||||
mc: &Mutation<'gc>,
|
mc: &Mutation<'gc>,
|
||||||
) -> Step {
|
) -> Step {
|
||||||
use PrimOpPhase::*;
|
use Continuation::*;
|
||||||
let phase_disc = reader.read_u8();
|
let cont = reader.read_u8();
|
||||||
let Ok(phase) = PrimOpPhase::try_from(phase_disc) else {
|
let Ok(cont) = Continuation::try_from(cont) else {
|
||||||
return m.finish_err(Error::eval_error("invalid primop phase"));
|
return m.finish_err(Error::eval_error("invalid primop phase"));
|
||||||
};
|
};
|
||||||
match phase {
|
match cont {
|
||||||
Abort => abort(m, ctx, reader, mc),
|
PAbort => abort(m, ctx, reader, mc),
|
||||||
|
|
||||||
All => all_entry(m, reader, mc),
|
PAll => all_entry(m, reader, mc),
|
||||||
AllCallPred => all_call_pred(m, reader, mc),
|
PAllCallPred => all_call_pred(m, reader, mc),
|
||||||
AllCheck => all_check(m, reader, mc),
|
PAllCheck => all_check(m, reader, mc),
|
||||||
|
|
||||||
Any => any_entry(m, reader, mc),
|
PAny => any_entry(m, reader, mc),
|
||||||
AnyCallPred => any_call_pred(m, reader, mc),
|
PAnyCallPred => any_call_pred(m, reader, mc),
|
||||||
AnyCheck => any_check(m, reader, mc),
|
PAnyCheck => any_check(m, reader, mc),
|
||||||
|
|
||||||
DeepSeq => deep_seq_force_top(m, reader, mc),
|
PDeepSeq => deep_seq_force_top(m, reader, mc),
|
||||||
DeepSeqPush => deep_seq_push(m, reader, mc),
|
PDeepSeqPush => deep_seq_push(m, reader, mc),
|
||||||
DeepSeqLoop => deep_seq_loop(m, reader, mc),
|
PDeepSeqLoop => deep_seq_loop(m, reader, mc),
|
||||||
Seq => seq(m, reader, mc),
|
PSeq => seq(m, reader, mc),
|
||||||
|
|
||||||
FilterForceList => filter_force_list(m, reader, mc),
|
PFilterForceList => filter_force_list(m, reader, mc),
|
||||||
FilterCallPred => filter_call_pred(m, reader, mc),
|
PFilterCallPred => filter_call_pred(m, reader, mc),
|
||||||
FilterCheck => filter_check(m, reader, mc),
|
PFilterCheck => filter_check(m, reader, mc),
|
||||||
|
|
||||||
FoldlStrict => foldl_strict_entry(m, reader, mc),
|
PFoldlStrict => foldl_strict_entry(m, reader, mc),
|
||||||
FoldlStrictEmpty => foldl_strict_empty(m, reader, mc),
|
PFoldlStrictEmpty => foldl_strict_empty(m, reader, mc),
|
||||||
FoldlStrictCall1 => foldl_strict_call1(m, reader, mc),
|
PFoldlStrictCall1 => foldl_strict_call1(m, reader, mc),
|
||||||
FoldlStrictCall2 => foldl_strict_call2(m, reader, mc),
|
PFoldlStrictCall2 => foldl_strict_call2(m, reader, mc),
|
||||||
FoldlStrictUpdate => foldl_strict_update(m, reader, mc),
|
PFoldlStrictUpdate => foldl_strict_update(m, reader, mc),
|
||||||
|
|
||||||
ForceResultShallow => force_result_shallow(m, ctx, reader, mc),
|
ForceResultShallow => force_result_shallow(m, ctx, reader, mc),
|
||||||
ForceResultShallowPush => force_result_shallow_push(m, ctx, reader, mc),
|
ForceResultShallowPush => force_result_shallow_push(m, ctx, reader, mc),
|
||||||
@@ -68,29 +68,30 @@ pub fn dispatch_primop<'gc, M: Machine<'gc>>(
|
|||||||
CallFunctor1 => call_functor_1(m, reader, mc),
|
CallFunctor1 => call_functor_1(m, reader, mc),
|
||||||
CallFunctor2 => call_functor_2(m, reader, mc),
|
CallFunctor2 => call_functor_2(m, reader, mc),
|
||||||
|
|
||||||
Import => import(m, ctx, reader, mc),
|
PImport => import(m, ctx, reader, mc),
|
||||||
ImportFinalize => import_finalize(m, ctx, reader),
|
PImportFinalize => import_finalize(m, ctx, reader),
|
||||||
ScopedImport => scoped_import(m, ctx, reader, mc),
|
PScopedImport => scoped_import(m, ctx, reader, mc),
|
||||||
ScopedImportFinalize => scoped_import_finalize(m, ctx, reader, mc),
|
PScopedImportFinalize => scoped_import_finalize(m, ctx, reader, mc),
|
||||||
|
|
||||||
PathExists => path_exists(m, ctx, reader, mc),
|
PPathExists => path_exists(m, ctx, reader, mc),
|
||||||
ToPath => to_path(m, ctx, reader, mc),
|
PToPath => to_path(m, ctx, reader, mc),
|
||||||
IsPath => is_path(m, reader, mc),
|
PIsPath => is_path(m, reader, mc),
|
||||||
ToString => to_string(m, ctx, reader, mc),
|
PToString => to_string(m, ctx, reader, mc),
|
||||||
TypeOf => type_of(m, ctx, reader, mc),
|
PTypeOf => type_of(m, ctx, reader, mc),
|
||||||
|
|
||||||
HasContext => has_context(m, ctx, reader, mc),
|
PHasContext => has_context(m, ctx, reader, mc),
|
||||||
GetContext => get_context(m, ctx, reader, mc),
|
PGetContext => get_context(m, ctx, reader, mc),
|
||||||
AppendContext => append_context(m, ctx, reader, mc),
|
PAppendContext => append_context(m, ctx, reader, mc),
|
||||||
AppendContextLoop => append_context_loop(m, ctx, reader, mc),
|
PAppendContextLoop => append_context_loop(m, ctx, reader, mc),
|
||||||
AppendContextEntryForced => append_context_entry_forced(m, ctx, reader, mc),
|
PAppendContextEntryForced => append_context_entry_forced(m, ctx, reader, mc),
|
||||||
AppendContextOutputsForced => append_context_outputs_forced(m, ctx, reader, mc),
|
PAppendContextOutputsForced => append_context_outputs_forced(m, ctx, reader, mc),
|
||||||
AppendContextOutputElementLoop => append_context_output_element_loop(m, ctx, reader, mc),
|
PAppendContextOutputElementLoop => append_context_output_element_loop(m, ctx, reader, mc),
|
||||||
AppendContextOutputElementForced => {
|
PAppendContextOutputElementForced => {
|
||||||
append_context_output_element_forced(m, ctx, reader, mc)
|
append_context_output_element_forced(m, ctx, reader, mc)
|
||||||
}
|
}
|
||||||
UnsafeDiscardStringContext => unsafe_discard_string_context(m, ctx, reader, mc),
|
|
||||||
UnsafeDiscardOutputDependency => unsafe_discard_output_dependency(m, ctx, reader, mc),
|
PUnsafeDiscardStringContext => unsafe_discard_string_context(m, ctx, reader, mc),
|
||||||
|
PUnsafeDiscardOutputDependency => unsafe_discard_output_dependency(m, ctx, reader, mc),
|
||||||
|
|
||||||
phase => todo!("primop phase {phase:?}"),
|
phase => todo!("primop phase {phase:?}"),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user