rename PrimOpPhase
This commit is contained in:
@@ -144,7 +144,7 @@ tail_fn!(op_make_closure, (reader, mc));
|
||||
tail_fn!(op_make_pattern_closure, (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_make_attrs, (ctx, reader, mc));
|
||||
@@ -235,7 +235,7 @@ table! {
|
||||
MakePatternClosure => op_make_pattern_closure,
|
||||
|
||||
Call => op_call,
|
||||
DispatchPrimOp => op_dispatch_primop,
|
||||
DispatchCont => op_dispatch_cont,
|
||||
Return => op_return,
|
||||
|
||||
MakeAttrs => op_make_attrs,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use fix_bytecode::PrimOpPhase;
|
||||
use fix_bytecode::Continuation;
|
||||
use fix_error::Error;
|
||||
use fix_runtime::{resolve_operand, *};
|
||||
use gc_arena::{Gc, Mutation, RefLock};
|
||||
@@ -31,7 +31,7 @@ pub(crate) fn call<'gc, M: Machine<'gc>>(
|
||||
thunk: None,
|
||||
env: m.env(),
|
||||
});
|
||||
reader.set_pc(PrimOpPhase::CallPattern.ip() as usize);
|
||||
reader.set_pc(Continuation::CallPattern.ip() as usize);
|
||||
return Step::Continue(());
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ pub(crate) fn call<'gc, M: Machine<'gc>>(
|
||||
m.push(arg);
|
||||
m.push(func.relax());
|
||||
m.push(functor);
|
||||
reader.set_pc(PrimOpPhase::CallFunctor1.ip() as usize);
|
||||
reader.set_pc(Continuation::CallFunctor1.ip() as usize);
|
||||
return Step::Continue(());
|
||||
} else {
|
||||
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::Shallow => {
|
||||
m.push(val.relax());
|
||||
reader.set_pc(PrimOpPhase::ForceResultShallow.ip() as usize);
|
||||
reader.set_pc(Continuation::ForceResultShallow.ip() as usize);
|
||||
return Step::Continue(());
|
||||
}
|
||||
ForceMode::Deep => {
|
||||
m.push(val.relax());
|
||||
m.push(val.relax());
|
||||
m.push_call_frame(CallFrame {
|
||||
pc: PrimOpPhase::ForceResultDeepFinish.ip() as usize,
|
||||
pc: Continuation::ForceResultDeepFinish.ip() as usize,
|
||||
thunk: None,
|
||||
env: m.env(),
|
||||
});
|
||||
m.inc_call_depth();
|
||||
reader.set_pc(PrimOpPhase::DeepSeq.ip() as usize);
|
||||
reader.set_pc(Continuation::PDeepSeq.ip() as usize);
|
||||
return Step::Continue(());
|
||||
}
|
||||
}
|
||||
@@ -171,11 +171,11 @@ pub(crate) fn op_return<'gc, M: Machine<'gc>>(
|
||||
}
|
||||
|
||||
#[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,
|
||||
ctx: &mut impl VmRuntimeCtx,
|
||||
reader: &mut BytecodeReader<'_>,
|
||||
mc: &Mutation<'gc>,
|
||||
) -> 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 fix_bytecode::PrimOpPhase;
|
||||
use fix_bytecode::Continuation;
|
||||
use fix_error::Error;
|
||||
use fix_lang::{BUILTINS, BuiltinId, StringId};
|
||||
use fix_runtime::{
|
||||
@@ -25,7 +25,7 @@ pub(crate) fn op_load_builtin<'gc, M: Machine<'gc>>(
|
||||
m.push(Value::new_inline(PrimOp {
|
||||
id,
|
||||
arity: BUILTINS[id as usize].1,
|
||||
dispatch_ip: PrimOpPhase::entry_for_builtin(id).ip(),
|
||||
dispatch_ip: Continuation::entry_for_builtin(id).ip(),
|
||||
}));
|
||||
Step::Continue(())
|
||||
}
|
||||
|
||||
+5
-3
@@ -7,7 +7,7 @@
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use fix_bytecode::{InstructionPtr, PrimOpPhase};
|
||||
use fix_bytecode::{InstructionPtr, Continuation};
|
||||
use fix_error::{Error, Result, Source};
|
||||
use fix_lang::{BUILTINS, BuiltinId, StringId};
|
||||
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 name = name.strip_prefix("__").unwrap_or(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((
|
||||
name,
|
||||
Value::new_inline(PrimOp {
|
||||
@@ -476,6 +476,8 @@ impl<'gc> Vm<'gc> {
|
||||
let mut fuel = Self::DEFAULT_FUEL_AMOUNT;
|
||||
|
||||
loop {
|
||||
use crate::instructions::op_dispatch_cont;
|
||||
|
||||
if fuel == 0 {
|
||||
return Action::Continue { pc: reader.pc() };
|
||||
}
|
||||
@@ -502,7 +504,7 @@ impl<'gc> Vm<'gc> {
|
||||
MakePatternClosure => op_make_pattern_closure(self, &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),
|
||||
|
||||
MakeAttrs => op_make_attrs(self, ctx, &mut reader, mc),
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//! See `fix-runtime/src/string_context.rs` for the
|
||||
//! `StringContextElem` type.
|
||||
|
||||
use fix_bytecode::PrimOpPhase;
|
||||
use fix_bytecode::Continuation;
|
||||
use fix_error::Error;
|
||||
use fix_lang::StringId;
|
||||
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_gc(acc));
|
||||
|
||||
reader.set_pc(PrimOpPhase::AppendContextLoop.ip() as usize);
|
||||
reader.set_pc(Continuation::PAppendContextLoop.ip() as usize);
|
||||
Step::Continue(())
|
||||
}
|
||||
|
||||
@@ -221,9 +221,9 @@ pub fn append_context_loop<'gc, M: Machine<'gc>>(
|
||||
0,
|
||||
reader,
|
||||
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(())
|
||||
}
|
||||
|
||||
@@ -296,9 +296,9 @@ pub fn append_context_entry_forced<'gc, M: Machine<'gc>>(
|
||||
0,
|
||||
reader,
|
||||
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(());
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ pub fn append_context_entry_forced<'gc, M: Machine<'gc>>(
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let idx_back = m.peek(1).as_inline::<i32>().unwrap();
|
||||
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(())
|
||||
}
|
||||
|
||||
@@ -327,12 +327,12 @@ pub fn append_context_outputs_forced<'gc, M: Machine<'gc>>(
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let idx_back = m.peek(1).as_inline::<i32>().unwrap();
|
||||
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(());
|
||||
}
|
||||
|
||||
m.push(Value::new_inline(0i32));
|
||||
reader.set_pc(PrimOpPhase::AppendContextOutputElementLoop.ip() as usize);
|
||||
reader.set_pc(Continuation::PAppendContextOutputElementLoop.ip() as usize);
|
||||
Step::Continue(())
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ pub fn append_context_output_element_loop<'gc, M: Machine<'gc>>(
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let idx_back = m.peek(1).as_inline::<i32>().unwrap();
|
||||
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(());
|
||||
}
|
||||
|
||||
@@ -365,9 +365,9 @@ pub fn append_context_output_element_loop<'gc, M: Machine<'gc>>(
|
||||
0,
|
||||
reader,
|
||||
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(())
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ pub fn append_context_output_element_forced<'gc, M: Machine<'gc>>(
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let oidx = m.peek(0).as_inline::<i32>().unwrap();
|
||||
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(())
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use fix_bytecode::PrimOpPhase;
|
||||
use fix_bytecode::Continuation;
|
||||
use fix_error::Error;
|
||||
use fix_runtime::{
|
||||
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(worklist));
|
||||
m.push(Value::new_inline(count));
|
||||
reader.set_pc(PrimOpPhase::DeepSeqPush.ip() as usize);
|
||||
reader.set_pc(Continuation::PDeepSeqPush.ip() as usize);
|
||||
Step::Continue(())
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ pub fn deep_seq_push<'gc, M: Machine<'gc>>(
|
||||
m.push(item);
|
||||
|
||||
// force item at TOS, resume at DeepSeqLoop after force
|
||||
m.force_slot_to_pc(0, reader, mc, PrimOpPhase::DeepSeqLoop.ip() as usize)?;
|
||||
reader.set_pc(PrimOpPhase::DeepSeqLoop.ip() as usize);
|
||||
m.force_slot_to_pc(0, reader, mc, Continuation::PDeepSeqLoop.ip() as usize)?;
|
||||
reader.set_pc(Continuation::PDeepSeqLoop.ip() as usize);
|
||||
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));
|
||||
reader.set_pc(PrimOpPhase::DeepSeqPush.ip() as usize);
|
||||
reader.set_pc(Continuation::PDeepSeqPush.ip() as usize);
|
||||
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(count as i32));
|
||||
reader.set_pc(PrimOpPhase::ForceResultShallowPush.ip() as usize);
|
||||
reader.set_pc(Continuation::ForceResultShallowPush.ip() as usize);
|
||||
Step::Continue(())
|
||||
}
|
||||
|
||||
@@ -225,9 +225,9 @@ pub fn force_result_shallow_push<'gc, M: Machine<'gc>>(
|
||||
0,
|
||||
reader,
|
||||
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(())
|
||||
}
|
||||
@@ -238,7 +238,7 @@ pub fn force_result_shallow_loop<'gc, M: Machine<'gc>>(
|
||||
_mc: &Mutation<'gc>,
|
||||
) -> Step {
|
||||
let _ = m.pop(); // forced child
|
||||
reader.set_pc(PrimOpPhase::ForceResultShallowPush.ip() as usize);
|
||||
reader.set_pc(Continuation::ForceResultShallowPush.ip() as usize);
|
||||
Step::Continue(())
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ pub fn call_functor_1<'gc, M: Machine<'gc>>(
|
||||
reader,
|
||||
mc,
|
||||
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::{
|
||||
AttrSet, BytecodeReader, CallFrame, List, Machine, MachineExt, NixNum, Null, Path, Step,
|
||||
StrictValue, Value, VmRuntimeCtx, VmRuntimeCtxExt,
|
||||
@@ -71,7 +71,7 @@ pub fn eq_step<'gc, M: Machine<'gc>>(
|
||||
.expect("non-empty rhs queue");
|
||||
m.push(lhs);
|
||||
m.push(rhs);
|
||||
reader.set_pc(PrimOpPhase::EqForce.ip() as usize);
|
||||
reader.set_pc(Continuation::EqForce.ip() as usize);
|
||||
Step::Continue(())
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ pub fn eq_force<'gc, M: Machine<'gc>>(
|
||||
) -> Step {
|
||||
let (lhs, rhs) = m.force_and_retry::<(StrictValue, StrictValue)>(reader, mc)?;
|
||||
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(())
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ fn enter_eq_machine<'gc, M: Machine<'gc>>(
|
||||
m.push(Value::new_inline(true));
|
||||
m.push(Value::new_gc(List::new(mc, lhs_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(())
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use fix_bytecode::PrimOpPhase;
|
||||
use fix_bytecode::Continuation;
|
||||
use fix_error::Error;
|
||||
use fix_lang::StringId;
|
||||
use fix_runtime::{
|
||||
@@ -43,7 +43,7 @@ pub fn import<'gc, M: Machine<'gc>>(
|
||||
m.push(Value::new_inline(path_sid));
|
||||
let env = m.env();
|
||||
m.push_call_frame(CallFrame {
|
||||
pc: PrimOpPhase::ImportFinalize.ip() as usize,
|
||||
pc: Continuation::PImportFinalize.ip() as usize,
|
||||
thunk: None,
|
||||
env,
|
||||
});
|
||||
@@ -111,7 +111,7 @@ pub fn scoped_import<'gc, M: Machine<'gc>>(
|
||||
|
||||
let env = m.env();
|
||||
m.push_call_frame(CallFrame {
|
||||
pc: PrimOpPhase::ScopedImportFinalize.ip() as usize,
|
||||
pc: Continuation::PScopedImportFinalize.ip() as usize,
|
||||
thunk: None,
|
||||
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 gc_arena::Mutation;
|
||||
|
||||
@@ -20,7 +20,7 @@ pub fn filter_force_list<'gc, M: Machine<'gc>>(
|
||||
// prepare stack layout: [ pred list idx acc ]
|
||||
m.push(Value::new_inline(0));
|
||||
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(())
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn filter_call_pred<'gc, M: Machine<'gc>>(
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let elem = m.peek_forced(2).as_gc::<List>().unwrap().inner.borrow()[idx as usize];
|
||||
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>>(
|
||||
@@ -64,7 +64,7 @@ pub fn filter_check<'gc, M: Machine<'gc>>(
|
||||
return m.return_from_primop(acc, reader);
|
||||
}
|
||||
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(())
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ pub fn foldl_strict_entry<'gc, M: Machine<'gc>>(
|
||||
};
|
||||
if list.inner.borrow().is_empty() {
|
||||
let _ = m.pop(); // list
|
||||
reader.set_pc(PrimOpPhase::FoldlStrictEmpty.ip() as usize);
|
||||
reader.set_pc(Continuation::PFoldlStrictEmpty.ip() as usize);
|
||||
return Step::Continue(());
|
||||
}
|
||||
let list_val = m.pop();
|
||||
@@ -96,7 +96,7 @@ pub fn foldl_strict_entry<'gc, M: Machine<'gc>>(
|
||||
m.push(list_val);
|
||||
m.push(Value::new_inline(0i32));
|
||||
m.push(nul_val);
|
||||
reader.set_pc(PrimOpPhase::FoldlStrictCall1.ip() as usize);
|
||||
reader.set_pc(Continuation::PFoldlStrictCall1.ip() as usize);
|
||||
Step::Continue(())
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ pub fn foldl_strict_call1<'gc, M: Machine<'gc>>(
|
||||
let op = m.peek_forced(3);
|
||||
let acc = m.peek(0);
|
||||
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>>(
|
||||
@@ -136,7 +136,7 @@ pub fn foldl_strict_call2<'gc, M: Machine<'gc>>(
|
||||
reader,
|
||||
mc,
|
||||
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);
|
||||
}
|
||||
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(())
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ pub fn all_entry<'gc, M: Machine<'gc>>(
|
||||
}
|
||||
// prepare stack layout: [ pred list idx ]
|
||||
m.push(Value::new_inline(0));
|
||||
reader.set_pc(PrimOpPhase::AllCallPred.ip() as usize);
|
||||
reader.set_pc(Continuation::PAllCallPred.ip() as usize);
|
||||
Step::Continue(())
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ pub fn all_call_pred<'gc, M: Machine<'gc>>(
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let elem = m.peek_forced(1).as_gc::<List>().unwrap().inner.borrow()[idx as usize];
|
||||
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>>(
|
||||
@@ -219,7 +219,7 @@ pub fn all_check<'gc, M: Machine<'gc>>(
|
||||
return m.return_from_primop(Value::new_inline(ret), reader);
|
||||
}
|
||||
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(())
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ pub fn any_entry<'gc, M: Machine<'gc>>(
|
||||
}
|
||||
// prepare stack layout: [ pred list idx ]
|
||||
m.push(Value::new_inline(0));
|
||||
reader.set_pc(PrimOpPhase::AnyCallPred.ip() as usize);
|
||||
reader.set_pc(Continuation::PAnyCallPred.ip() as usize);
|
||||
Step::Continue(())
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ pub fn any_call_pred<'gc, M: Machine<'gc>>(
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let elem = m.peek_forced(1).as_gc::<List>().unwrap().inner.borrow()[idx as usize];
|
||||
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>>(
|
||||
@@ -278,6 +278,6 @@ pub fn any_check<'gc, M: Machine<'gc>>(
|
||||
return m.return_from_primop(Value::new_inline(ret), reader);
|
||||
}
|
||||
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(())
|
||||
}
|
||||
|
||||
+45
-44
@@ -10,7 +10,7 @@ pub use context::*;
|
||||
pub use control::*;
|
||||
pub use conv::*;
|
||||
pub use eq::*;
|
||||
use fix_bytecode::PrimOpPhase;
|
||||
use fix_bytecode::Continuation;
|
||||
use fix_error::Error;
|
||||
use fix_runtime::{BytecodeReader, Machine, Step, VmRuntimeCtx};
|
||||
use gc_arena::Mutation;
|
||||
@@ -19,42 +19,42 @@ pub use list::*;
|
||||
pub use path::*;
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub fn dispatch_primop<'gc, M: Machine<'gc>>(
|
||||
pub fn dispatch_cont<'gc, M: Machine<'gc>>(
|
||||
m: &mut M,
|
||||
ctx: &mut impl VmRuntimeCtx,
|
||||
reader: &mut BytecodeReader<'_>,
|
||||
mc: &Mutation<'gc>,
|
||||
) -> Step {
|
||||
use PrimOpPhase::*;
|
||||
let phase_disc = reader.read_u8();
|
||||
let Ok(phase) = PrimOpPhase::try_from(phase_disc) else {
|
||||
use Continuation::*;
|
||||
let cont = reader.read_u8();
|
||||
let Ok(cont) = Continuation::try_from(cont) else {
|
||||
return m.finish_err(Error::eval_error("invalid primop phase"));
|
||||
};
|
||||
match phase {
|
||||
Abort => abort(m, ctx, reader, mc),
|
||||
match cont {
|
||||
PAbort => abort(m, ctx, reader, mc),
|
||||
|
||||
All => all_entry(m, reader, mc),
|
||||
AllCallPred => all_call_pred(m, reader, mc),
|
||||
AllCheck => all_check(m, reader, mc),
|
||||
PAll => all_entry(m, reader, mc),
|
||||
PAllCallPred => all_call_pred(m, reader, mc),
|
||||
PAllCheck => all_check(m, reader, mc),
|
||||
|
||||
Any => any_entry(m, reader, mc),
|
||||
AnyCallPred => any_call_pred(m, reader, mc),
|
||||
AnyCheck => any_check(m, reader, mc),
|
||||
PAny => any_entry(m, reader, mc),
|
||||
PAnyCallPred => any_call_pred(m, reader, mc),
|
||||
PAnyCheck => any_check(m, reader, mc),
|
||||
|
||||
DeepSeq => deep_seq_force_top(m, reader, mc),
|
||||
DeepSeqPush => deep_seq_push(m, reader, mc),
|
||||
DeepSeqLoop => deep_seq_loop(m, reader, mc),
|
||||
Seq => seq(m, reader, mc),
|
||||
PDeepSeq => deep_seq_force_top(m, reader, mc),
|
||||
PDeepSeqPush => deep_seq_push(m, reader, mc),
|
||||
PDeepSeqLoop => deep_seq_loop(m, reader, mc),
|
||||
PSeq => seq(m, reader, mc),
|
||||
|
||||
FilterForceList => filter_force_list(m, reader, mc),
|
||||
FilterCallPred => filter_call_pred(m, reader, mc),
|
||||
FilterCheck => filter_check(m, reader, mc),
|
||||
PFilterForceList => filter_force_list(m, reader, mc),
|
||||
PFilterCallPred => filter_call_pred(m, reader, mc),
|
||||
PFilterCheck => filter_check(m, reader, mc),
|
||||
|
||||
FoldlStrict => foldl_strict_entry(m, reader, mc),
|
||||
FoldlStrictEmpty => foldl_strict_empty(m, reader, mc),
|
||||
FoldlStrictCall1 => foldl_strict_call1(m, reader, mc),
|
||||
FoldlStrictCall2 => foldl_strict_call2(m, reader, mc),
|
||||
FoldlStrictUpdate => foldl_strict_update(m, reader, mc),
|
||||
PFoldlStrict => foldl_strict_entry(m, reader, mc),
|
||||
PFoldlStrictEmpty => foldl_strict_empty(m, reader, mc),
|
||||
PFoldlStrictCall1 => foldl_strict_call1(m, reader, mc),
|
||||
PFoldlStrictCall2 => foldl_strict_call2(m, reader, mc),
|
||||
PFoldlStrictUpdate => foldl_strict_update(m, reader, mc),
|
||||
|
||||
ForceResultShallow => force_result_shallow(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),
|
||||
CallFunctor2 => call_functor_2(m, reader, mc),
|
||||
|
||||
Import => import(m, ctx, reader, mc),
|
||||
ImportFinalize => import_finalize(m, ctx, reader),
|
||||
ScopedImport => scoped_import(m, ctx, reader, mc),
|
||||
ScopedImportFinalize => scoped_import_finalize(m, ctx, reader, mc),
|
||||
PImport => import(m, ctx, reader, mc),
|
||||
PImportFinalize => import_finalize(m, ctx, reader),
|
||||
PScopedImport => scoped_import(m, ctx, reader, mc),
|
||||
PScopedImportFinalize => scoped_import_finalize(m, ctx, reader, mc),
|
||||
|
||||
PathExists => path_exists(m, ctx, reader, mc),
|
||||
ToPath => to_path(m, ctx, reader, mc),
|
||||
IsPath => is_path(m, reader, mc),
|
||||
ToString => to_string(m, ctx, reader, mc),
|
||||
TypeOf => type_of(m, ctx, reader, mc),
|
||||
PPathExists => path_exists(m, ctx, reader, mc),
|
||||
PToPath => to_path(m, ctx, reader, mc),
|
||||
PIsPath => is_path(m, reader, mc),
|
||||
PToString => to_string(m, ctx, reader, mc),
|
||||
PTypeOf => type_of(m, ctx, reader, mc),
|
||||
|
||||
HasContext => has_context(m, ctx, reader, mc),
|
||||
GetContext => get_context(m, ctx, reader, mc),
|
||||
AppendContext => append_context(m, ctx, reader, mc),
|
||||
AppendContextLoop => append_context_loop(m, ctx, reader, mc),
|
||||
AppendContextEntryForced => append_context_entry_forced(m, ctx, reader, mc),
|
||||
AppendContextOutputsForced => append_context_outputs_forced(m, ctx, reader, mc),
|
||||
AppendContextOutputElementLoop => append_context_output_element_loop(m, ctx, reader, mc),
|
||||
AppendContextOutputElementForced => {
|
||||
PHasContext => has_context(m, ctx, reader, mc),
|
||||
PGetContext => get_context(m, ctx, reader, mc),
|
||||
PAppendContext => append_context(m, ctx, reader, mc),
|
||||
PAppendContextLoop => append_context_loop(m, ctx, reader, mc),
|
||||
PAppendContextEntryForced => append_context_entry_forced(m, ctx, reader, mc),
|
||||
PAppendContextOutputsForced => append_context_outputs_forced(m, ctx, reader, mc),
|
||||
PAppendContextOutputElementLoop => append_context_output_element_loop(m, ctx, reader, mc),
|
||||
PAppendContextOutputElementForced => {
|
||||
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:?}"),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user