about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/aterm-helper.pl15
-rw-r--r--src/libexpr/eval.cc7
-rw-r--r--src/libexpr/eval.hh1
3 files changed, 16 insertions, 7 deletions
diff --git a/src/aterm-helper.pl b/src/aterm-helper.pl
index 1feff0ccd098..3bb466fe3bb8 100755
--- a/src/aterm-helper.pl
+++ b/src/aterm-helper.pl
@@ -99,8 +99,17 @@ while (<STDIN>) {
         
         print IMPL "AFun sym$funname = 0;\n";
         
+        if ($arity == 0) {
+            print HEADER "extern ATerm const$funname;\n\n";
+            print IMPL "ATerm const$funname = 0;\n";
+        }
+        
+        print HEADER "static inline $result make$funname($formals) __attribute__ ((pure, nothrow));\n";
         print HEADER "static inline $result make$funname($formals) {\n";
-        if ($arity <= 6) {
+        if ($arity == 0) {
+            print HEADER "    return const$funname;\n";
+        }
+        elsif ($arity <= 6) {
             print HEADER "    return (ATerm) ATmakeAppl$arity(sym$funname$args);\n";
         } else {
             $args =~ s/^,//;
@@ -119,6 +128,10 @@ while (<STDIN>) {
 
         $init .= "    sym$funname = ATmakeAFun(\"$const\", $arity, ATfalse);\n";
         $init .= "    ATprotectAFun(sym$funname);\n";
+        if ($arity == 0) {
+            $init .= "    const$funname = (ATerm) ATmakeAppl0(sym$funname);\n";
+            $init .= "    ATprotect(&const$funname);\n";
+        }
     }
 
     elsif (/^\s*(\w+)\s*=\s*(.*)$/) {
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 1ee9da3b9bc8..6d2b20e53946 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -6,8 +6,6 @@
 EvalState::EvalState()
     : normalForms(32768, 50)
 {
-    blackHole = makeBlackHole();
-    
     nrEvaluated = nrCached = 0;
 
     initNixExprHelpers();
@@ -490,14 +488,14 @@ Expr evalExpr(EvalState & state, Expr e)
        previously evaluated expressions. */
     Expr nf = state.normalForms.get(e);
     if (nf) {
-        if (nf == state.blackHole)
+        if (nf == makeBlackHole())
             throw Error("infinite recursion encountered");
         state.nrCached++;
         return nf;
     }
 
     /* Otherwise, evaluate and memoize. */
-    state.normalForms.set(e, state.blackHole);
+    state.normalForms.set(e, makeBlackHole());
     try {
         nf = evalExpr2(state, e);
     } catch (Error & err) {
@@ -536,5 +534,4 @@ void printEvalStats(EvalState & state)
         % state.nrEvaluated % state.nrCached
         % ((float) state.nrCached / (float) state.nrEvaluated * 100)
         % AT_calcAllocatedSize());
-    sleep(100);
 }
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index 54a612b367ef..c881969add69 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -29,7 +29,6 @@ struct EvalState
     DrvRoots drvRoots;
     DrvHashes drvHashes; /* normalised derivation hashes */
     SrcToStore srcToStore; 
-    Expr blackHole;
 
     unsigned int nrEvaluated;
     unsigned int nrCached;