refactor(tvix/eval): merge OpCall & OpTailCall
As applies are thunked, there was no situation where OpCall could be emitted. In practice, all calls were already tail calls. Change-Id: Id0d441dcdd86f804d7cddd0cc14f589bbfc75e5b Reviewed-on: https://cl.tvl.fyi/c/depot/+/8147 Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
parent
e5ff12e04c
commit
9cebae9b56
3 changed files with 0 additions and 24 deletions
|
|
@ -1019,11 +1019,6 @@ impl Compiler<'_> {
|
|||
// lambda as a constant.
|
||||
let mut compiled = self.contexts.pop().unwrap();
|
||||
|
||||
// Check if tail-call optimisation is possible and perform it.
|
||||
if self.dead_scope == 0 {
|
||||
optimise_tail_call(&mut compiled.lambda.chunk);
|
||||
}
|
||||
|
||||
// Capturing the with stack counts as an upvalue, as it is
|
||||
// emitted as an upvalue data instruction.
|
||||
if compiled.captures_with_stack {
|
||||
|
|
@ -1288,19 +1283,6 @@ fn expr_static_attr_str(node: &ast::Attr) -> Option<SmolStr> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Perform tail-call optimisation if the last call within a
|
||||
/// compiled chunk is another call.
|
||||
fn optimise_tail_call(chunk: &mut Chunk) {
|
||||
let last_op = chunk
|
||||
.code
|
||||
.last_mut()
|
||||
.expect("compiler bug: chunk should never be empty");
|
||||
|
||||
if matches!(last_op, OpCode::OpCall) {
|
||||
*last_op = OpCode::OpTailCall;
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a delayed source-only builtin compilation, for a builtin
|
||||
/// which is written in Nix code.
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue