[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 11 commits: rts: Fix `prompt#` when profiling is enabled

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu Feb 23 10:07:44 UTC 2023



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
3bb4ffe7 by Alexis King at 2023-02-23T05:07:34-05:00
rts: Fix `prompt#` when profiling is enabled

This commit also adds a new -Dk RTS option to the debug RTS to assist
debugging continuation captures. Currently, the printed information is
quite minimal, but more can be added in the future if it proves to be
useful when debugging future issues.

fixes #23001

- - - - -
e186f2b9 by Ben Gamari at 2023-02-23T05:07:34-05:00
Bump terminfo submodule to 0.4.1.6

- - - - -
00be487f by Ben Gamari at 2023-02-23T05:07:34-05:00
Bump unix submodule to preliminary 2.8 release

- - - - -
fd81a531 by Ben Gamari at 2023-02-23T05:07:34-05:00
Bump deepseq submodule to 1.4.8.1

- - - - -
c90c2884 by Ben Gamari at 2023-02-23T05:07:34-05:00
Bump directory to 1.3.8.1

- - - - -
4c73bdc5 by Ben Gamari at 2023-02-23T05:07:34-05:00
Bump process submodule to v1.6.17.0

- - - - -
7b4a315c by Ben Gamari at 2023-02-23T05:07:34-05:00
Bump hsc2hs submodule to 0.68.8

- - - - -
8b434b70 by Ben Gamari at 2023-02-23T05:07:34-05:00
Bump array submodule to 0.5.4.0

- - - - -
b7aab9e3 by Ben Gamari at 2023-02-23T05:07:34-05:00
Bump Cabal submodule to 3.9 pre-release

- - - - -
b430a54b by Ben Gamari at 2023-02-23T05:07:34-05:00
Bump filepath submodule to 1.4.100.1

- - - - -
6452f658 by Ben Gamari at 2023-02-23T05:07:34-05:00
Bump haskeline submodule to 0.8.2.1

- - - - -


17 changed files:

- docs/users_guide/runtime_control.rst
- libraries/Cabal
- libraries/array
- libraries/deepseq
- libraries/directory
- libraries/filepath
- libraries/haskeline
- libraries/process
- libraries/terminfo
- libraries/unix
- rts/Continuation.c
- rts/ContinuationOps.cmm
- rts/RtsFlags.c
- rts/Trace.h
- rts/include/rts/Flags.h
- testsuite/tests/rts/continuations/all.T
- utils/hsc2hs


Changes:

=====================================
docs/users_guide/runtime_control.rst
=====================================
@@ -1367,6 +1367,7 @@ recommended for everyday use!
 .. rts-flag::  -Dc  DEBUG: program coverage
 .. rts-flag::  -Dr  DEBUG: sparks
 .. rts-flag::  -DC  DEBUG: compact
+.. rts-flag::  -Dk  DEBUG: continuation
 
     Debug messages will be sent to the binary event log file instead of
     stdout if the :rts-flag:`-l ⟨flags⟩` option is added. This might be useful


=====================================
libraries/Cabal
=====================================
@@ -1 +1 @@
-Subproject commit 6cd29789ca866464dc3af89f62c98c41264ce3cd
+Subproject commit 280a7a71e495da8f25ae33dbc6e743526b9106f9


=====================================
libraries/array
=====================================
@@ -1 +1 @@
-Subproject commit f7a498b880a1fff833699d8417bac155d58ed59e
+Subproject commit f487b8de85f2b271a3831c14ab6439b9bc9b8343


=====================================
libraries/deepseq
=====================================
@@ -1 +1 @@
-Subproject commit 7e77698d6a78981bc2649df78021a6c33a5d3913
+Subproject commit 0bfe57809f8ecaf1921b82a6791d1ecc317d1998


=====================================
libraries/directory
=====================================
@@ -1 +1 @@
-Subproject commit 7f9066137c694ab7cef9a4ebd8c19a281fad42e4
+Subproject commit 3ae36d84e44737fa9800d74d55ae1e30b75628cf


=====================================
libraries/filepath
=====================================
@@ -1 +1 @@
-Subproject commit 7139cd3383a2aae440a57b5604a8182d9a983715
+Subproject commit bb0e5cd49655b41bd3209b100f7a5a74698cbe83


=====================================
libraries/haskeline
=====================================
@@ -1 +1 @@
-Subproject commit ad40faf532ca86ae6d0839a299234db2ce4fc424
+Subproject commit 1c2ad91edc936a9836d1ad80a26f8be03a7d8bb0


=====================================
libraries/process
=====================================
@@ -1 +1 @@
-Subproject commit d9a8e6e749d2d60422037f3ef4733d521f18a7fc
+Subproject commit e60ab049b92238b0111654589f17b6ee68249f01


=====================================
libraries/terminfo
=====================================
@@ -1 +1 @@
-Subproject commit 0a05f06bc8a56c43578ce06d4ef1339ee70fb3fc
+Subproject commit 98100776edcf33796ddf2e752233e6ef179b876d


=====================================
libraries/unix
=====================================
@@ -1 +1 @@
-Subproject commit 98adc732bfbfca4fef945d546ecbaae13952a950
+Subproject commit 978e4e781b3a26a3d6b2f17efba7dbc176eca798


=====================================
rts/Continuation.c
=====================================
@@ -12,6 +12,7 @@
 #include "sm/Storage.h"
 #include "sm/Sanity.h"
 #include "Continuation.h"
+#include "Printer.h"
 #include "Threads.h"
 
 #include <string.h>
@@ -392,7 +393,14 @@ StgClosure *captureContinuationAndAbort(Capability *cap, StgTSO *tso, StgPromptT
 
   /* --- Phase 1: Find the matching prompt frame ---------------------------- */
 
+  IF_DEBUG(continuation,
+    debugBelch("captureContinuationAndAbort: searching for prompt\n");
+    debugBelch("  prompt_tag = "); printClosure(prompt_tag));
+
   while (true) {
+    IF_DEBUG(continuation,
+      printStackChunk(frame, frame + stack_frame_sizeW((StgClosure *)frame)));
+
     const StgInfoTable *info_ptr = ((StgClosure *)frame)->header.info;
     const StgRetInfoTable *info = get_ret_itbl((StgClosure *)frame);
     StgWord chunk_words = frame - stack->sp;
@@ -429,6 +437,8 @@ StgClosure *captureContinuationAndAbort(Capability *cap, StgTSO *tso, StgPromptT
                   || info->i.type == ATOMICALLY_FRAME
                   || info->i.type == CATCH_RETRY_FRAME
                   || info->i.type == CATCH_STM_FRAME)) {
+      IF_DEBUG(continuation,
+        debugBelch("captureContinuationAndAbort: could not find prompt, bailing out\n"));
       return NULL; // Bail out
     }
 
@@ -452,6 +462,10 @@ StgClosure *captureContinuationAndAbort(Capability *cap, StgTSO *tso, StgPromptT
 
   /* --- Phase 2: Perform the capture --------------------------------------- */
 
+  IF_DEBUG(continuation,
+    debugBelch("captureContinuationAndAbort: found prompt, "
+               "capturing %" FMT_Word " words of stack\n", total_words));
+
   dirty_TSO(cap, tso);
   dirty_STACK(cap, stack);
 


=====================================
rts/ContinuationOps.cmm
=====================================
@@ -49,7 +49,12 @@ stg_newPromptTagzh()
   return (tag);
 }
 
-INFO_TABLE_RET(stg_prompt_frame, RET_SMALL, W_ info_ptr, P_ tag /* :: PromptTag# a */)
+#define PROMPT_FRAME_FIELDS(w_,p_,info_ptr,p1,p2,tag) \
+  w_ info_ptr,                                        \
+  PROF_HDR_FIELDS(w_,p1,p2)                           \
+  p_ tag
+
+INFO_TABLE_RET(stg_prompt_frame, RET_SMALL, PROMPT_FRAME_FIELDS(W_,P_, info_ptr, p1, p2, tag /* :: PromptTag# a */))
   return (P_ ret /* :: a */)
 {
   return (ret);
@@ -61,7 +66,9 @@ stg_promptzh(P_ tag /* :: PromptTag# a */, P_ io /* :: IO a */)
   STK_CHK_GEN();
   TICK_UNKNOWN_CALL();
   TICK_SLOW_CALL_fast_v();
-  jump stg_ap_v_fast (stg_prompt_frame_info, tag) (io);
+  jump stg_ap_v_fast
+    (PROMPT_FRAME_FIELDS(,,stg_prompt_frame_info, CCCS, 0, tag))
+    (io);
 }
 
 /* --------------------------------------------------------------------------


=====================================
rts/RtsFlags.c
=====================================
@@ -205,6 +205,7 @@ void initRtsFlagsDefaults(void)
     RtsFlags.DebugFlags.sparks          = false;
     RtsFlags.DebugFlags.numa            = false;
     RtsFlags.DebugFlags.compact         = false;
+    RtsFlags.DebugFlags.continuation    = false;
 
 #if defined(PROFILING)
     RtsFlags.CcFlags.doCostCentres      = COST_CENTRES_NONE;
@@ -476,6 +477,7 @@ usage_text[] = {
 "  -Dc  DEBUG: program coverage",
 "  -Dr  DEBUG: sparks",
 "  -DC  DEBUG: compact",
+"  -Dk  DEBUG: continuation",
 "",
 "     NOTE: DEBUG events are sent to stderr by default; add -l to create a",
 "     binary event log file instead.",
@@ -2190,6 +2192,9 @@ static void read_debug_flags(const char* arg)
         case 'C':
             RtsFlags.DebugFlags.compact = true;
             break;
+        case 'k':
+            RtsFlags.DebugFlags.continuation = true;
+            break;
         default:
             bad_option( arg );
         }


=====================================
rts/Trace.h
=====================================
@@ -67,6 +67,7 @@ enum CapsetType { CapsetTypeCustom = CAPSET_TYPE_CUSTOM,
 #define DEBUG_hpc         RtsFlags.DebugFlags.hpc
 #define DEBUG_sparks      RtsFlags.DebugFlags.sparks
 #define DEBUG_compact     RtsFlags.DebugFlags.compact
+#define DEBUG_continuation RtsFlags.DebugFlags.continuation
 
 // Event-enabled flags
 // These semantically booleans but we use a dense packing to minimize their


=====================================
rts/include/rts/Flags.h
=====================================
@@ -113,6 +113,7 @@ typedef struct _DEBUG_FLAGS {
     bool sparks;         /* 'r' */
     bool numa;           /* '--debug-numa' */
     bool compact;        /* 'C' */
+    bool continuation;   /* 'k' */
 } DEBUG_FLAGS;
 
 /* See Note [Synchronization of flags and base APIs] */


=====================================
testsuite/tests/rts/continuations/all.T
=====================================
@@ -1,4 +1,6 @@
 setTestOpts(js_broken(22261))
+if have_profiling():
+  setTestOpts(extra_ways(['prof']))
 
 test('cont_simple_shift', [extra_files(['ContIO.hs'])], multimod_compile_and_run, ['cont_simple_shift', ''])
 test('cont_exn_masking', [extra_files(['ContIO.hs'])], multimod_compile_and_run, ['cont_exn_masking', ''])


=====================================
utils/hsc2hs
=====================================
@@ -1 +1 @@
-Subproject commit 0811ae8f29d0cc2591bbe89bc034ae14143d0443
+Subproject commit 1ba092932f86c1fda15091d355ba7975b8554437



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/97fcf73d91bf64ad6388f0e3f2c766729e7c8757...6452f658f07403e001a073fc4c6585c71b47080e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/97fcf73d91bf64ad6388f0e3f2c766729e7c8757...6452f658f07403e001a073fc4c6585c71b47080e
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230223/ba9f8a58/attachment-0001.html>


More information about the ghc-commits mailing list