refactor(3p/nix/libexpr): Back Nix lists with std::vector
This change does away with the previous special-casing of lists of certain element sizes, and the use of raw C-style arrays. Lists are now backed by a std::vector of nix::Value*, which uses the traceable GC allocator. This change is unfortunately quite noisy because the accessor methods were updated/removed accordingly, so all callsites of Nix-related lists have changed. For some operations in primops.cc where keeping the previous code structure would have been more difficult with a "proper" vector, the implementation has been replaced with std::vector methods. For example, list concatenation now uses appropriate range inserts. Anecdotally the performance of this is about equal, to even slightly better, than the previous implementation. All language tests pass and the depot paths I've used for testing still evaluate. Change-Id: Ib5eca6c0207429cb323a330c838c3a2200b2c693 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1266 Tested-by: BuildkiteCI Reviewed-by: isomer <isomer@tvl.fyi> Reviewed-by: Kane York <rikingcoding@gmail.com> Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
		
							parent
							
								
									56614c75e4
								
							
						
					
					
						commit
						cdc1a0bb6e
					
				
					 16 changed files with 163 additions and 231 deletions
				
			
		
							
								
								
									
										11
									
								
								third_party/nix/src/libexpr/eval.hh
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								third_party/nix/src/libexpr/eval.hh
									
										
									
									
										vendored
									
									
								
							|  | @ -260,12 +260,19 @@ class EvalState { | |||
| 
 | ||||
|   Value* allocAttr(Value& vAttrs, const Symbol& name); | ||||
| 
 | ||||
|   void mkList(Value& v, size_t size); | ||||
|   // Create a list value from the specified vector.
 | ||||
|   void mkList(Value& v, NixList* list); | ||||
| 
 | ||||
|   // Create a list value, allocating as many elements as specified in
 | ||||
|   // size. This is used for the many cases in this codebase where
 | ||||
|   // assignment happens into the preallocated list.
 | ||||
|   void mkList(Value& v, size_t size = 0); | ||||
| 
 | ||||
|   void mkAttrs(Value& v, size_t capacity); | ||||
|   void mkThunk_(Value& v, Expr* expr); | ||||
|   void mkPos(Value& v, Pos* pos); | ||||
| 
 | ||||
|   void concatLists(Value& v, size_t nrLists, Value** lists, const Pos& pos); | ||||
|   void concatLists(Value& v, const NixList& lists, const Pos& pos); | ||||
| 
 | ||||
|   /* Print statistics. */ | ||||
|   void printStats(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue