Implement #2191 (traceCcs# -- prints CCS of a value when available -- take 3)
authorSamuel Bronson <naesten@gmail.com>
Tue, 27 Jan 2009 08:48:25 +0000 (08:48 +0000)
committerSamuel Bronson <naesten@gmail.com>
Tue, 27 Jan 2009 08:48:25 +0000 (08:48 +0000)
In this version, I untag R1 before using it, and even enter R2 at the
end rather than simply returning it (which didn't work right when R2
was a thunk).

compiler/prelude/primops.txt.pp
includes/StgMiscClosures.h
rts/Linker.c
rts/PrimOps.cmm

index 1e41453..3779a79 100644 (file)
@@ -1743,6 +1743,17 @@ primop  GetApStackValOp "getApStackVal#" GenPrimOp
    out_of_line = True
 
 ------------------------------------------------------------------------
+section "Misc"
+        {These aren't nearly as wired in as Etc...}
+------------------------------------------------------------------------
+
+primop  TraceCcsOp "traceCcs#" GenPrimOp
+   a -> b -> b
+   with
+   has_side_effects = True
+   out_of_line = True
+
+------------------------------------------------------------------------
 section "Etc" 
        {Miscellaneous built-ins}
 ------------------------------------------------------------------------
index 460adeb..94244a9 100644 (file)
@@ -606,6 +606,8 @@ RTS_FUN(getSparkzh_fast);
 
 RTS_FUN(noDuplicatezh_fast);
 
+RTS_FUN(traceCcszh_fast);
+
 /* Other misc stuff */
 // See wiki:Commentary/Compiler/Backends/PprC#Prototypes
 
index ae1da56..474cd81 100644 (file)
@@ -856,6 +856,7 @@ typedef struct _RtsSymbolVal {
       SymI_NeedsProto(rts_stop_on_exception)           \
       SymI_HasProto(stopTimer)                         \
       SymI_HasProto(n_capabilities)                    \
+      SymI_HasProto(traceCcszh_fast)                    \
       RTS_USER_SIGNALS_SYMBOLS
 
 #ifdef SUPPORT_LONG_LONGS
index dc60ff2..a6e221b 100644 (file)
@@ -2362,6 +2362,26 @@ getApStackValzh_fast
    RET_NP(ok,val);
 }
 
+/* -----------------------------------------------------------------------------
+   Misc. primitives
+   -------------------------------------------------------------------------- */
+
+// Write the cost center stack of the first argument on stderr; return
+// the second.  Possibly only makes sense for already evaluated
+// things?
+traceCcszh_fast
+{
+    W_ ccs;
+
+#ifdef PROFILING
+    ccs = StgHeader_ccs(UNTAG(R1));
+    foreign "C" fprintCCS_stderr(ccs "ptr") [R2];
+#endif
+
+    R1 = R2;
+    ENTER();
+}
+
 getSparkzh_fast
 {
    W_ spark;