fix(3p/nix/libexpr): Make new Bindings class visible to GC

This commit is contained in:
Vincent Ambo 2020-05-22 16:35:21 +01:00
parent 68e6e92a20
commit e24466c795
2 changed files with 9 additions and 6 deletions

View file

@ -1,6 +1,9 @@
#include "attr-set.hh" #include "attr-set.hh"
#include <new>
#include <absl/container/btree_map.h> #include <absl/container/btree_map.h>
#include <gc/gc_cpp.h>
#include "eval-inline.hh" #include "eval-inline.hh"
@ -46,12 +49,11 @@ void Bindings::merge(Bindings* other) {
attributes_.swap(other->attributes_); attributes_.swap(other->attributes_);
} }
// /* Allocate a new array of attributes for an attribute set with a specific // Allocate a new attribute set, making it visible to the garbage collector.
// capacity. The space is implicitly reserved after the Bindings structure. Bindings* EvalState::allocBindings(size_t _capacity) {
// */ return new (GC) Bindings;
Bindings* EvalState::allocBindings(size_t _capacity) { return new Bindings; } }
// TODO(tazjin): What's Value? What's going on here?
void EvalState::mkAttrs(Value& v, size_t capacity) { void EvalState::mkAttrs(Value& v, size_t capacity) {
if (capacity == 0) { if (capacity == 0) {
v = vEmptySet; v = vEmptySet;
@ -59,7 +61,7 @@ void EvalState::mkAttrs(Value& v, size_t capacity) {
} }
clearValue(v); clearValue(v);
v.type = tAttrs; v.type = tAttrs;
v.attrs = new Bindings; v.attrs = new (GC) Bindings;
nrAttrsets++; nrAttrsets++;
nrAttrsInAttrsets += capacity; nrAttrsInAttrsets += capacity;
} }

View file

@ -53,6 +53,7 @@ libexpr_link_list = [
libexpr_link_args = [ libexpr_link_args = [
'-lpthread', '-lpthread',
'-lgccpp',
] ]
libexpr_cxx_args = [] libexpr_cxx_args = []