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

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu Feb 23 19:29:24 UTC 2023



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


Commits:
cb73b428 by Alexis King at 2023-02-23T14:29:13-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

- - - - -
c2fc5f94 by sheaf at 2023-02-23T14:29:15-05:00
Explicit migration timeline for loopy SC solving

This patch updates the warning message introduced in commit
9fb4ca89bff9873e5f6a6849fa22a349c94deaae to specify an explicit
migration timeline: GHC will no longer support this constraint solving
mechanism starting from GHC 9.10.

Fixes #22912

- - - - -


15 changed files:

- compiler/GHC/Tc/Errors/Ppr.hs
- docs/users_guide/runtime_control.rst
- rts/Continuation.c
- rts/ContinuationOps.cmm
- rts/RtsFlags.c
- rts/Trace.h
- rts/include/rts/Flags.h
- testsuite/tests/rts/continuations/all.T
- testsuite/tests/typecheck/should_compile/T20666b.stderr
- testsuite/tests/typecheck/should_compile/T22891.stderr
- testsuite/tests/typecheck/should_compile/T22912.stderr
- testsuite/tests/typecheck/should_fail/T20666.stderr
- testsuite/tests/typecheck/should_fail/T20666a.stderr
- testsuite/tests/typecheck/should_fail/T6161.stderr
- testsuite/tests/typecheck/should_fail/tcfail223.stderr


Changes:

=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -1321,7 +1321,7 @@ instance Diagnostic TcRnMessage where
                  , nest 2 $ pprCtOrigin (ctLocOrigin wtd_loc) <> comma
                  , text "in a way that might turn out to loop at runtime." ]
         warning
-          = vcat [ text "Future versions of GHC will turn this warning into an error." ]
+          = vcat [ text "Starting from GHC 9.10, this warning will turn into an error." ]
         user_manual =
           vcat [ text "See the user manual, § Undecidable instances and loopy superclasses." ]
 


=====================================
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


=====================================
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', ''])


=====================================
testsuite/tests/typecheck/should_compile/T20666b.stderr
=====================================
@@ -3,7 +3,7 @@ T20666b.hs:11:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)]
     I am solving the constraint ‘Eq (F [a])’,
       arising from the superclasses of an instance declaration,
     in a way that might turn out to loop at runtime.
-    Future versions of GHC will turn this warning into an error.
+    Starting from GHC 9.10, this warning will turn into an error.
     See the user manual, § Undecidable instances and loopy superclasses.
     Suggested fix:
       Add the constraint ‘Eq (F [a])’ to the instance context,


=====================================
testsuite/tests/typecheck/should_compile/T22891.stderr
=====================================
@@ -3,7 +3,7 @@ T22891.hs:9:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)]
     I am solving the constraint ‘Foo f’,
       arising from the superclasses of an instance declaration,
     in a way that might turn out to loop at runtime.
-    Future versions of GHC will turn this warning into an error.
+    Starting from GHC 9.10, this warning will turn into an error.
     See the user manual, § Undecidable instances and loopy superclasses.
     Suggested fix:
       Add the constraint ‘Foo f’ to the instance context,


=====================================
testsuite/tests/typecheck/should_compile/T22912.stderr
=====================================
@@ -4,7 +4,7 @@ T22912.hs:17:16: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)]
       arising from the head of a quantified constraint
       arising from a use of ‘go’,
     in a way that might turn out to loop at runtime.
-    Future versions of GHC will turn this warning into an error.
+    Starting from GHC 9.10, this warning will turn into an error.
     See the user manual, § Undecidable instances and loopy superclasses.
     Suggested fix:
       Add the constraint ‘Implies


=====================================
testsuite/tests/typecheck/should_fail/T20666.stderr
=====================================
@@ -3,7 +3,7 @@ T20666.hs:13:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)]
     I am solving the constraint ‘Show (T c)’,
       arising from the superclasses of an instance declaration,
     in a way that might turn out to loop at runtime.
-    Future versions of GHC will turn this warning into an error.
+    Starting from GHC 9.10, this warning will turn into an error.
     See the user manual, § Undecidable instances and loopy superclasses.
     Suggested fix:
       Add the constraint ‘Show (T c)’ to the instance context,
@@ -13,7 +13,7 @@ T20666.hs:17:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)]
     I am solving the constraint ‘Show (T c)’,
       arising from the superclasses of an instance declaration,
     in a way that might turn out to loop at runtime.
-    Future versions of GHC will turn this warning into an error.
+    Starting from GHC 9.10, this warning will turn into an error.
     See the user manual, § Undecidable instances and loopy superclasses.
     Suggested fix:
       Add the constraint ‘Show (T c)’ to the instance context,


=====================================
testsuite/tests/typecheck/should_fail/T20666a.stderr
=====================================
@@ -3,7 +3,7 @@ T20666a.hs:11:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)]
     I am solving the constraint ‘Eq (F [a])’,
       arising from the superclasses of an instance declaration,
     in a way that might turn out to loop at runtime.
-    Future versions of GHC will turn this warning into an error.
+    Starting from GHC 9.10, this warning will turn into an error.
     See the user manual, § Undecidable instances and loopy superclasses.
     Suggested fix:
       Add the constraint ‘Eq (F [a])’ to the instance context,


=====================================
testsuite/tests/typecheck/should_fail/T6161.stderr
=====================================
@@ -3,7 +3,7 @@ T6161.hs:19:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)]
     I am solving the constraint ‘Super (Fam a)’,
       arising from the superclasses of an instance declaration,
     in a way that might turn out to loop at runtime.
-    Future versions of GHC will turn this warning into an error.
+    Starting from GHC 9.10, this warning will turn into an error.
     See the user manual, § Undecidable instances and loopy superclasses.
     Suggested fix:
       Add the constraint ‘Super (Fam a)’ to the instance context,


=====================================
testsuite/tests/typecheck/should_fail/tcfail223.stderr
=====================================
@@ -3,7 +3,7 @@ tcfail223.hs:10:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault
     I am solving the constraint ‘Class1 a’,
       arising from the superclasses of an instance declaration,
     in a way that might turn out to loop at runtime.
-    Future versions of GHC will turn this warning into an error.
+    Starting from GHC 9.10, this warning will turn into an error.
     See the user manual, § Undecidable instances and loopy superclasses.
     Suggested fix:
       Add the constraint ‘Class1 a’ to the instance context,



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c18dea31f38998cf5c67cc3ddad064d1416dc326...c2fc5f945af9c414609d1903e19bc57e7aed512f

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c18dea31f38998cf5c67cc3ddad064d1416dc326...c2fc5f945af9c414609d1903e19bc57e7aed512f
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/3fdbd1da/attachment-0001.html>


More information about the ghc-commits mailing list