feat(3p/nix): Add function to allocate a Value in traceable memory

Backported from:
b3e5eea4a9
fcd048a526

Intentionally skipped because we have not backported the JSON changes:
9f46f54de4

Did not apply changes ni primops.cc, because those look suspect and
are also based on something that we don't have in our tree.

Change-Id: I837787ce9f2c90267bc39fce15177980d209d4e9
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1253
Tested-by: BuildkiteCI
Reviewed-by: isomer <isomer@tvl.fyi>
This commit is contained in:
Eelco Dolstra 2020-04-16 16:28:07 +02:00 committed by tazjin
parent 014436eb4a
commit 80eaa1eaf9
5 changed files with 19 additions and 10 deletions

View file

@ -5,10 +5,13 @@
#include <cstring>
#include <fstream>
#include <iostream>
#include <memory>
#include <new>
#include <optional>
#include <variant>
#define GC_INCLUDE_NEW
#include <absl/strings/match.h>
#include <gc/gc.h>
#include <gc/gc_cpp.h>
@ -40,6 +43,10 @@ static char* dupString(const char* s) {
return t;
}
std::shared_ptr<Value*> allocRootValue(Value* v) {
return std::allocate_shared<Value*>(traceable_allocator<Value*>(), v);
}
static void printValue(std::ostream& str, std::set<const Value*>& active,
const Value& v) {
checkInterrupt();