refactor(tvix/eval): simplify self-reference check

Checking the computed depth and stack slot against the computed depth
and stack slot is equivalent to just checking the indices into the
locals vector against each other (i.e. "is the slot we're compiling
into the slot we're accessing?")

Change-Id: Ie85a68df073e3b2e3d9aba7fe8634c48eada81fc
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7059
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2022-10-22 17:55:10 +03:00 committed by tazjin
parent c9bf7c4cf1
commit 546fcf51cd

View file

@ -1014,7 +1014,7 @@ impl Compiler<'_> {
self.scope_mut().mark_needs_finaliser(slot);
} else {
// a self-reference
if this_depth == target_depth && this_stack_slot == stack_idx {
if slot == idx {
self.scope_mut().mark_must_thunk(slot);
}
self.push_op(OpCode::DataLocalIdx(stack_idx), &upvalue.span);