about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/nixexpr.hh
diff options
context:
space:
mode:
authorKane York <kanepyork@gmail.com>2020-08-13T22·18-0700
committerkanepyork <rikingcoding@gmail.com>2020-08-14T00·35+0000
commit72e61aa584c3e3bbafbdc539959a2db8e0f123ef (patch)
treed74d5ed8508ab9845812752c51451f870dcc482c /third_party/nix/src/libexpr/nixexpr.hh
parentd4f5fcef66beeff2e0cbd641ac83a5b2a67e3006 (diff)
refactor(tvix): completely remove boehm gc r/1646
We have decided that leaking memory is a better fate than random,
non-debuggable memory corruption. Future CLs will begin changing
various fields to std::unique_ptr and std::shared_ptr.

It turns out that disabling the GC does not have disasterous impact.
The Nix evaluator only runs on the client CLI, never in any long-
running process. Even the REPL does not leak too badly under this
change, because it uses one EvalState for the duration of the REPL.

Building an explicitly tracing garbage collector is likely in the
future of this project, but that giant amount of work cannot be
done under a nix evaluator that is constantly crashing. We need to
restore development velocity here, and this is the best way we've
figured out to do it.

Change-Id: I2fcda8fcee853c15a9a5e22eca7c5a784bc2bf76
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1720
Reviewed-by: glittershark <grfn@gws.fyi>
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
Diffstat (limited to 'third_party/nix/src/libexpr/nixexpr.hh')
-rw-r--r--third_party/nix/src/libexpr/nixexpr.hh30
1 files changed, 11 insertions, 19 deletions
diff --git a/third_party/nix/src/libexpr/nixexpr.hh b/third_party/nix/src/libexpr/nixexpr.hh
index 6edfb2a187..22b5f871f0 100644
--- a/third_party/nix/src/libexpr/nixexpr.hh
+++ b/third_party/nix/src/libexpr/nixexpr.hh
@@ -73,19 +73,16 @@ struct StaticEnv;
 
 /* An attribute path is a sequence of attribute names. */
 using AttrName = std::variant<Symbol, Expr*>;
+using AttrPath = std::vector<AttrName>;
+using AttrNameVector = std::vector<AttrName>;
 
-typedef std::vector<AttrName, traceable_allocator<AttrName>> AttrPath;
-
-using AttrNameVector =
-    std::vector<nix::AttrName, traceable_allocator<nix::AttrName>>;
-
-using VectorExprs = std::vector<nix::Expr*, traceable_allocator<nix::Expr*>>;
+using VectorExprs = std::vector<nix::Expr*>;
 
 std::string showAttrPath(const AttrPath& attrPath);
 
 /* Abstract syntax of Nix expressions. */
 
-struct Expr : public gc {
+struct Expr {
   virtual ~Expr(){};
   virtual void show(std::ostream& str) const;
   virtual void bindVars(const StaticEnv& env);
@@ -191,7 +188,7 @@ struct ExprOpHasAttr : Expr {
 struct ExprAttrs : Expr {
   bool recursive;
 
-  struct AttrDef : public gc {
+  struct AttrDef {
     bool inherited;
     Expr* e;
     Pos pos;
@@ -201,22 +198,17 @@ struct ExprAttrs : Expr {
     AttrDef(){};
   };
 
-  typedef absl::flat_hash_map<
-      Symbol, AttrDef, absl::container_internal::hash_default_hash<Symbol>,
-      absl::container_internal::hash_default_eq<Symbol>,
-      traceable_allocator<std::pair<const Symbol, AttrDef>>>
-      AttrDefs;
+  using AttrDefs = absl::flat_hash_map<Symbol, AttrDef>;
   AttrDefs attrs;
 
-  struct DynamicAttrDef : public gc {
+  struct DynamicAttrDef {
     Expr *nameExpr, *valueExpr;
     Pos pos;
     DynamicAttrDef(Expr* nameExpr, Expr* valueExpr, const Pos& pos)
         : nameExpr(nameExpr), valueExpr(valueExpr), pos(pos){};
   };
 
-  typedef std::vector<DynamicAttrDef, traceable_allocator<DynamicAttrDef>>
-      DynamicAttrDefs;
+  using DynamicAttrDefs = std::vector<DynamicAttrDef>;
   DynamicAttrDefs dynamicAttrs;
 
   ExprAttrs() : recursive(false){};
@@ -229,15 +221,15 @@ struct ExprList : Expr {
   COMMON_METHODS
 };
 
-struct Formal : public gc {
+struct Formal {
   Symbol name;
   Expr* def;  // def = default, not definition
   Formal(const Symbol& name, Expr* def) : name(name), def(def){};
 };
 
 // Describes structured function arguments (e.g. `{ a }: ...`)
-struct Formals : public gc {
-  typedef std::list<Formal, traceable_allocator<Formal>> Formals_;
+struct Formals {
+  using Formals_ = std::list<Formal>;
   Formals_ formals;
   std::set<Symbol> argNames;  // used during parsing
   bool ellipsis;