feat(tvix/eval): emit OpFinalise when local scopes are complete
With this change, the runtime can correctly capture deferred upvalues. Change-Id: I1e43b7b1ac2553b1812424adfc8bd08ef77bf1ea Reviewed-on: https://cl.tvl.fyi/c/depot/+/6339 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
		
							parent
							
								
									5c4e102ac8
								
							
						
					
					
						commit
						68aad6d4cf
					
				
					 3 changed files with 13 additions and 0 deletions
				
			
		|  | @ -678,6 +678,7 @@ impl Compiler { | |||
|         } | ||||
| 
 | ||||
|         // Second pass to place the values in the correct stack slots.
 | ||||
|         let indices: Vec<usize> = entries.iter().map(|(idx, _)| *idx).collect(); | ||||
|         for (idx, value) in entries.into_iter() { | ||||
|             self.compile(Some(idx), value); | ||||
| 
 | ||||
|  | @ -686,6 +687,13 @@ impl Compiler { | |||
|             self.mark_initialised(idx); | ||||
|         } | ||||
| 
 | ||||
|         // Third pass to emit finaliser instructions if necessary.
 | ||||
|         for idx in indices { | ||||
|             if self.scope().locals[idx].needs_finaliser { | ||||
|                 self.chunk().push_op(OpCode::OpFinalise(StackIdx(idx))); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // Deal with the body, then clean up the locals afterwards.
 | ||||
|         self.compile(None, node.body().unwrap()); | ||||
|         self.end_scope(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue