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

Commits:

21 changed files:

Changes:

  • docs/users_guide/index.rst
    ... ... @@ -29,6 +29,7 @@ Contents:
    29 29
        eventlog-formats
    
    30 30
        glossary
    
    31 31
        editing-guide
    
    32
    +   genindex
    
    32 33
     
    
    33 34
     
    
    34 35
     Indices and tables
    

  • docs/users_guide/runtime_control.rst
    ... ... @@ -1588,6 +1588,7 @@ recommended for everyday use!
    1588 1588
     
    
    1589 1589
     .. rts-flag::  -Ds  DEBUG: scheduler
    
    1590 1590
     .. rts-flag::  -Di  DEBUG: interpreter
    
    1591
    +.. rts-flag::  -DI  DEBUG: IPE
    
    1591 1592
     .. rts-flag::  -Dw  DEBUG: weak
    
    1592 1593
     .. rts-flag::  -DG  DEBUG: gccafs
    
    1593 1594
     .. rts-flag::  -Dg  DEBUG: gc
    

  • hadrian/hadrian.cabal
    ... ... @@ -190,4 +190,4 @@ executable hadrian
    190 190
         if flag(selftest)
    
    191 191
           other-modules:   Rules.Selftest
    
    192 192
           cpp-options:     -DHADRIAN_ENABLE_SELFTEST
    
    193
    -      build-depends:   QuickCheck           >= 2.6     && < 2.15
    193
    +      build-depends:   QuickCheck           >= 2.6     && < 2.18

  • hadrian/src/Flavour.hs
    ... ... @@ -384,9 +384,15 @@ omitPragmas = addArgs
    384 384
     -- | Build stage2 dependencies with options to enable IPE debugging
    
    385 385
     -- information.
    
    386 386
     enableIPE :: Flavour -> Flavour
    
    387
    -enableIPE = addArgs
    
    388
    -    $ notStage0 ? builder (Ghc CompileHs)
    
    389
    -    ? pure ["-finfo-table-map", "-fdistinct-constructor-tables"]
    
    387
    +enableIPE =
    
    388
    +  addArgs $
    
    389
    +    mconcat
    
    390
    +      [ notStage0
    
    391
    +          ? builder (Ghc CompileHs)
    
    392
    +          ? pure
    
    393
    +            ["-finfo-table-map", "-fdistinct-constructor-tables"],
    
    394
    +        builder Testsuite ? arg "--config=ghc_with_ipe=True"
    
    395
    +      ]
    
    390 396
     
    
    391 397
     enableLateCCS :: Flavour -> Flavour
    
    392 398
     enableLateCCS = addArgs
    

  • libraries/ghc-compact/tests/all.T
    ... ... @@ -20,7 +20,8 @@ test('compact_gc', [fragile_for(17253, ['ghci']), ignore_stdout], compile_and_ru
    20 20
     # this test computes closure sizes and those are affected
    
    21 21
     # by the ghci and prof ways, because of BCOs and profiling headers.
    
    22 22
     # Optimization levels slightly change what is/isn't shared so only run in normal mode
    
    23
    -test('compact_share', only_ways(['normal']), compile_and_run, [''])
    
    23
    +test('compact_share', [only_ways(['normal']), when(ghc_with_ipe(), skip)], # IPE changes allocation/layout affecting compactSize output.
    
    24
    +     compile_and_run, [''])
    
    24 25
     test('compact_bench', [ ignore_stdout, extra_run_opts('100') ],
    
    25 26
                            compile_and_run, [''])
    
    26 27
     test('T17044', normal, compile_and_run, [''])
    

  • libraries/ghc-internal/tests/backtraces/all.T
    ... ... @@ -2,5 +2,5 @@ test('T14532a', [], compile_and_run, [''])
    2 2
     test('T14532b', [], compile_and_run, [''])
    
    3 3
     test('T26507', [ when(have_profiling(), extra_ways(['prof']))
    
    4 4
                    , when(js_arch(), skip)
    
    5
    -	       , exit_code(1)], compile_and_run, [''])
    
    6
    -
    5
    +               , when(ghc_with_ipe(), skip) # IPE builds include an IPE backtrace section on stderr.
    
    6
    +               , exit_code(1)], compile_and_run, [''])

  • rts/AllocArray.c
    ... ... @@ -5,6 +5,7 @@
    5 5
     
    
    6 6
     StgMutArrPtrs *allocateMutArrPtrs (Capability *cap,
    
    7 7
                                        StgWord nelements,
    
    8
    +                                   StgClosure *init,
    
    8 9
                                        CostCentreStack *ccs USED_IF_PROFILING)
    
    9 10
     {
    
    10 11
         /* All sizes in words */
    
    ... ... @@ -25,6 +26,12 @@ StgMutArrPtrs *allocateMutArrPtrs (Capability *cap,
    25 26
         arr->ptrs = nelements;
    
    26 27
         arr->size = arrsize;
    
    27 28
     
    
    29
    +    if (init != NULL) {
    
    30
    +        for (StgWord i = 0; i < nelements; ++i) {
    
    31
    +            arr->payload[i] = init;
    
    32
    +        }
    
    33
    +    }
    
    34
    +
    
    28 35
         /* Initialize the card array. Note that memset needs sizes in bytes. */
    
    29 36
         memset(&(arr->payload[nelements]), 0, mutArrPtrsCards(nelements));
    
    30 37
     
    
    ... ... @@ -33,6 +40,7 @@ StgMutArrPtrs *allocateMutArrPtrs (Capability *cap,
    33 40
     
    
    34 41
     StgSmallMutArrPtrs *allocateSmallMutArrPtrs (Capability *cap,
    
    35 42
                                                  StgWord nelements,
    
    43
    +                                             StgClosure *init,
    
    36 44
                                                  CostCentreStack *ccs
    
    37 45
                                                    USED_IF_PROFILING)
    
    38 46
     {
    
    ... ... @@ -47,6 +55,13 @@ StgSmallMutArrPtrs *allocateSmallMutArrPtrs (Capability *cap,
    47 55
         /* No write barrier needed since this is a new allocation. */
    
    48 56
         SET_HDR(arr, &stg_SMALL_MUT_ARR_PTRS_DIRTY_info, ccs);
    
    49 57
         arr->ptrs = nelements;
    
    58
    +
    
    59
    +    if (init != NULL) {
    
    60
    +        for (StgWord i = 0; i < nelements; ++i) {
    
    61
    +            arr->payload[i] = init;
    
    62
    +        }
    
    63
    +    }
    
    64
    +
    
    50 65
         return arr;
    
    51 66
     }
    
    52 67
     
    

  • rts/AllocArray.h
    ... ... @@ -21,16 +21,19 @@
    21 21
      */
    
    22 22
     
    
    23 23
     /* Allocate a StgMutArrPtrs for a given number of elements. It is allocated in
    
    24
    - * the DIRTY state.
    
    24
    + * the DIRTY state. If init is non-NULL, initialize payload elements to init.
    
    25 25
      */
    
    26 26
     StgMutArrPtrs *allocateMutArrPtrs (Capability *cap,
    
    27 27
                                        StgWord nelements,
    
    28
    +                                   StgClosure *init,
    
    28 29
                                        CostCentreStack *ccs);
    
    29 30
     
    
    30
    -/* Allocate a StgSmallMutArrPtrs for a given number of elements.
    
    31
    +/* Allocate a StgSmallMutArrPtrs for a given number of elements. If init is
    
    32
    + * non-NULL, initialize payload elements to init.
    
    31 33
      */
    
    32 34
     StgSmallMutArrPtrs *allocateSmallMutArrPtrs (Capability *cap,
    
    33 35
                                                  StgWord nelements,
    
    36
    +                                             StgClosure *init,
    
    34 37
                                                  CostCentreStack *ccs);
    
    35 38
     
    
    36 39
     /* Allocate a StgArrBytes for a given number of bytes.
    

  • rts/ClosureTable.c
    ... ... @@ -46,7 +46,7 @@ bool enlargeClosureTable(Capability *cap, ClosureTable *t, int newcapacity)
    46 46
         ASSERT(newcapacity > oldcapacity);
    
    47 47
     
    
    48 48
         StgMutArrPtrs *newarr;
    
    49
    -    newarr = allocateMutArrPtrs(cap, newcapacity, CCS_SYSTEM_OR_NULL);
    
    49
    +    newarr = allocateMutArrPtrs(cap, newcapacity, NULL, CCS_SYSTEM_OR_NULL);
    
    50 50
         if (RTS_UNLIKELY(newarr == NULL)) return false;
    
    51 51
     
    
    52 52
         StgArrBytes *newfree;
    
    ... ... @@ -276,4 +276,3 @@ static bool isCompactClosureTable(ClosureTable *t)
    276 276
         }
    
    277 277
         return isCompact;
    
    278 278
     }
    279
    -

  • rts/Heap.c
    ... ... @@ -279,7 +279,7 @@ StgMutArrPtrs *heap_view_closurePtrs(Capability *cap, StgClosure *closure) {
    279 279
         StgClosure **ptrs = (StgClosure **) stgMallocBytes(sizeof(StgClosure *) * size, "heap_view_closurePtrs");
    
    280 280
         StgWord nptrs = collect_pointers(closure, ptrs);
    
    281 281
     
    
    282
    -    StgMutArrPtrs *arr = allocateMutArrPtrs(cap, nptrs, cap->r.rCCCS);
    
    282
    +    StgMutArrPtrs *arr = allocateMutArrPtrs(cap, nptrs, NULL, cap->r.rCCCS);
    
    283 283
         if (RTS_UNLIKELY(arr == NULL)) goto end;
    
    284 284
         SET_INFO((StgClosure *) arr, &stg_MUT_ARR_PTRS_FROZEN_CLEAN_info);
    
    285 285
     
    

  • rts/PrimOps.cmm
    ... ... @@ -386,24 +386,11 @@ stg_newArrayzh ( W_ n /* words */, gcptr init )
    386 386
     
    
    387 387
         again: MAYBE_GC(again);
    
    388 388
     
    
    389
    -    ("ptr" arr) = ccall allocateMutArrPtrs(MyCapability() "ptr", n, CCCS);
    
    389
    +    ("ptr" arr) = ccall allocateMutArrPtrs(MyCapability() "ptr", n, init "ptr", CCCS);
    
    390 390
         if (arr == NULL) (likely: False) {
    
    391 391
             jump stg_raisezh(HsIface_heapOverflow_closure(W_[ghc_hs_iface]));
    
    392 392
         }
    
    393 393
     
    
    394
    -    // Initialise all elements of the array with the value init
    
    395
    -    W_ p;
    
    396
    -    p = arr + SIZEOF_StgMutArrPtrs;
    
    397
    -    // Avoid the shift for `WDS(n)` in the inner loop
    
    398
    -    W_ limit;
    
    399
    -    limit = arr + SIZEOF_StgMutArrPtrs + WDS(n);
    
    400
    -  for:
    
    401
    -    if (p < limit) (likely: True) {
    
    402
    -        W_[p] = init;
    
    403
    -        p = p + WDS(1);
    
    404
    -        goto for;
    
    405
    -    }
    
    406
    -
    
    407 394
         return (arr);
    
    408 395
     }
    
    409 396
     
    
    ... ... @@ -496,24 +483,11 @@ stg_newSmallArrayzh ( W_ n /* words */, gcptr init )
    496 483
     
    
    497 484
         again: MAYBE_GC(again);
    
    498 485
     
    
    499
    -    ("ptr" arr) = ccall allocateSmallMutArrPtrs(MyCapability() "ptr", n, CCCS);
    
    486
    +    ("ptr" arr) = ccall allocateSmallMutArrPtrs(MyCapability() "ptr", n, init "ptr", CCCS);
    
    500 487
         if (arr == NULL) (likely: False) {
    
    501 488
             jump stg_raisezh(HsIface_heapOverflow_closure(W_[ghc_hs_iface]));
    
    502 489
         }
    
    503 490
     
    
    504
    -    // Initialise all elements of the array with the value init
    
    505
    -    W_ p;
    
    506
    -    p = arr + SIZEOF_StgSmallMutArrPtrs;
    
    507
    -    // Avoid the shift for `WDS(n)` in the inner loop
    
    508
    -    W_ limit;
    
    509
    -    limit = arr + SIZEOF_StgSmallMutArrPtrs + WDS(n);
    
    510
    -  for:
    
    511
    -    if (p < limit) (likely: True) {
    
    512
    -        W_[p] = init;
    
    513
    -        p = p + WDS(1);
    
    514
    -        goto for;
    
    515
    -    }
    
    516
    -
    
    517 491
         return (arr);
    
    518 492
     }
    
    519 493
     
    

  • rts/RtsFlags.c
    ... ... @@ -209,6 +209,8 @@ void initRtsFlagsDefaults(void)
    209 209
         RtsFlags.DebugFlags.numa            = false;
    
    210 210
         RtsFlags.DebugFlags.compact         = false;
    
    211 211
         RtsFlags.DebugFlags.continuation    = false;
    
    212
    +    RtsFlags.DebugFlags.iomanager       = false;
    
    213
    +    RtsFlags.DebugFlags.ipe             = false;
    
    212 214
     
    
    213 215
     #if defined(PROFILING)
    
    214 216
         RtsFlags.CcFlags.doCostCentres      = COST_CENTRES_NONE;
    
    ... ... @@ -482,6 +484,7 @@ usage_text[] = {
    482 484
     #if defined(DEBUG)
    
    483 485
     "  -Ds  DEBUG: scheduler",
    
    484 486
     "  -Di  DEBUG: interpreter",
    
    487
    +"  -DI  DEBUG: IPE",
    
    485 488
     "  -Dw  DEBUG: weak",
    
    486 489
     "  -DG  DEBUG: gccafs",
    
    487 490
     "  -Dg  DEBUG: gc",
    
    ... ... @@ -2311,6 +2314,9 @@ static void read_debug_flags(const char* arg)
    2311 2314
             case 'o':
    
    2312 2315
                 RtsFlags.DebugFlags.iomanager = true;
    
    2313 2316
                 break;
    
    2317
    +        case 'I':
    
    2318
    +            RtsFlags.DebugFlags.ipe = true;
    
    2319
    +            break;
    
    2314 2320
             default:
    
    2315 2321
                 bad_option( arg );
    
    2316 2322
             }
    

  • rts/Threads.c
    ... ... @@ -894,7 +894,7 @@ StgMutArrPtrs *listThreads(Capability *cap)
    894 894
         }
    
    895 895
     
    
    896 896
         // Allocate a suitably-sized array...
    
    897
    -    StgMutArrPtrs *arr = allocateMutArrPtrs(cap, n_threads, cap->r.rCCCS);
    
    897
    +    StgMutArrPtrs *arr = allocateMutArrPtrs(cap, n_threads, NULL, cap->r.rCCCS);
    
    898 898
         if (RTS_UNLIKELY(arr == NULL)) goto end;
    
    899 899
     
    
    900 900
         // Populate it...
    

  • rts/Trace.c
    ... ... @@ -685,7 +685,8 @@ void traceHeapProfSampleString(const char *label, StgWord residency)
    685 685
     void traceIPE(const InfoProvEnt *ipe)
    
    686 686
     {
    
    687 687
     #if defined(DEBUG)
    
    688
    -    if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
    
    688
    +    if (RtsFlags.TraceFlags.tracing == TRACE_STDERR
    
    689
    +        && RtsFlags.DebugFlags.ipe) {
    
    689 690
             ACQUIRE_LOCK(&trace_utx);
    
    690 691
     
    
    691 692
             char closure_desc_buf[CLOSURE_DESC_BUFFER_SIZE] = {};
    

  • rts/Weak.c
    ... ... @@ -146,7 +146,7 @@ scheduleFinalizers(Capability *cap, StgWeak *list)
    146 146
     
    
    147 147
         debugTrace(DEBUG_weak, "weak: batching %d finalizers", n);
    
    148 148
     
    
    149
    -    StgMutArrPtrs *arr = allocateMutArrPtrs(cap, n, CCS_SYSTEM_OR_NULL);
    
    149
    +    StgMutArrPtrs *arr = allocateMutArrPtrs(cap, n, NULL, CCS_SYSTEM_OR_NULL);
    
    150 150
         if (RTS_UNLIKELY(arr == NULL)) exitHeapOverflow();
    
    151 151
         // No write barrier needed here; this array is only going to referred to by this core.
    
    152 152
         SET_INFO((StgClosure *) arr, &stg_MUT_ARR_PTRS_FROZEN_CLEAN_info);
    

  • rts/include/rts/Flags.h
    ... ... @@ -118,6 +118,7 @@ typedef struct _DEBUG_FLAGS {
    118 118
         bool compact;        /* 'C' */
    
    119 119
         bool continuation;   /* 'k' */
    
    120 120
         bool iomanager;      /* 'o' */
    
    121
    +    bool ipe;            /* 'I' */
    
    121 122
     } DEBUG_FLAGS;
    
    122 123
     
    
    123 124
     /* See Note [Synchronization of flags and base APIs] */
    

  • testsuite/driver/testglobals.py
    ... ... @@ -72,6 +72,10 @@ class TestConfig:
    72 72
             # Was the compiler compiled with -debug?
    
    73 73
             self.debug_rts = False
    
    74 74
     
    
    75
    +        # Were the compiler + libraries built with IPE-related options
    
    76
    +        # (e.g. -finfo-table-map, -fdistinct-constructor-tables)?
    
    77
    +        self.ghc_with_ipe = False
    
    78
    +
    
    75 79
             # Was the compiler compiled with LLVM?
    
    76 80
             self.ghc_built_by_llvm = False
    
    77 81
     
    

  • testsuite/driver/testlib.py
    ... ... @@ -1074,6 +1074,9 @@ def have_profiling( ) -> bool:
    1074 1074
     def have_threaded( ) -> bool:
    
    1075 1075
         return config.ghc_with_threaded_rts
    
    1076 1076
     
    
    1077
    +def ghc_with_ipe( ) -> bool:
    
    1078
    +    return config.ghc_with_ipe
    
    1079
    +
    
    1077 1080
     def in_tree_compiler( ) -> bool:
    
    1078 1081
         return config.in_tree_compiler
    
    1079 1082
     
    

  • testsuite/tests/rts/Makefile
    ... ... @@ -140,7 +140,7 @@ T20199:
    140 140
     .PHONY: EventlogOutput_IPE
    
    141 141
     EventlogOutput_IPE:
    
    142 142
     	"$(TEST_HC)" $(TEST_HC_OPTS) -debug -finfo-table-map -v0 EventlogOutput.hs
    
    143
    -	./EventlogOutput +RTS -va 2> EventlogOutput_IPE.stderr.log
    
    143
    +	./EventlogOutput +RTS -va -DI 2> EventlogOutput_IPE.stderr.log
    
    144 144
     	grep "IPE:" EventlogOutput_IPE.stderr.log
    
    145 145
     
    
    146 146
     .PHONY: T23142
    

  • testsuite/tests/rts/all.T
    ... ... @@ -535,6 +535,7 @@ test('T13676',
    535 535
     test('InitEventLogging',
    
    536 536
          [ only_ways(['normal'])
    
    537 537
          , extra_run_opts('+RTS -RTS')
    
    538
    +     , when(ghc_with_ipe(), skip) # IPE builds can change eventlog writer call counts.
    
    538 539
          , req_c
    
    539 540
          ],
    
    540 541
          compile_and_run, ['InitEventLogging_c.c'])
    
    ... ... @@ -588,6 +589,7 @@ test('cloneThreadStack', [req_c, only_ways(['threaded1']), extra_ways(['threaded
    588 589
     
    
    589 590
     test('decodeMyStack',
    
    590 591
       [ omit_ghci, js_broken(22261) # cloneMyStack# not yet implemented
    
    592
    +  , when(ghc_with_ipe(), skip) # IPE builds can change decoded stack output.
    
    591 593
       ], compile_and_run, ['-finfo-table-map'])
    
    592 594
     
    
    593 595
     # Options:
    
    ... ... @@ -595,6 +597,7 @@ test('decodeMyStack',
    595 597
     test('decodeMyStack_underflowFrames',
    
    596 598
       [ extra_run_opts('+RTS -kc8K -RTS')
    
    597 599
       , omit_ghci, js_broken(22261) # cloneMyStack# not yet implemented
    
    600
    +  , when(ghc_with_ipe(), skip) # IPE builds can change decoded stack layout/length.
    
    598 601
       ], compile_and_run, ['-finfo-table-map -rtsopts'])
    
    599 602
     
    
    600 603
     # -finfo-table-map intentionally missing
    
    ... ... @@ -602,6 +605,7 @@ test('decodeMyStack_emptyListForMissingFlag',
    602 605
       [ ignore_stdout
    
    603 606
       , ignore_stderr
    
    604 607
       , js_broken(22261) # cloneMyStack# not yet implemented
    
    608
    +  , when(ghc_with_ipe(), skip) # IPE builds can populate IPE info even without -finfo-table-map on this module.
    
    605 609
       ], compile_and_run, [''])
    
    606 610
     
    
    607 611
     # Tests RTS flag parsing. Skipped on JS as it uses a distinct RTS.
    
    ... ... @@ -646,7 +650,7 @@ test('T25280', [unless(opsys('linux'),skip),req_process,js_skip], compile_and_ru
    646 650
     test('T25560', [req_c_rts, ignore_stderr], compile_and_run, [''])
    
    647 651
     
    
    648 652
     test('TestProddableBlockSet', [req_c_rts], multimod_compile_and_run, ['TestProddableBlockSet.c', '-no-hs-main'])
    
    649
    -test('T22859', 
    
    653
    +test('T22859',
    
    650 654
          [js_skip,
    
    651 655
           # This test is vulnerable to changes in allocation behaviour, so we disable it in some ways
    
    652 656
           when(arch('wasm32'), skip),
    

  • testsuite/tests/rts/ipe/all.T
    ... ... @@ -8,7 +8,7 @@ test('ipeMap', [extra_files(['ipe_lib.c', 'ipe_lib.h']), c_src, omit_ghci], comp
    8 8
     test('ipeEventLog',
    
    9 9
          [ c_src,
    
    10 10
            extra_files(['ipe_lib.c', 'ipe_lib.h']),
    
    11
    -       extra_run_opts('+RTS -va -RTS'),
    
    11
    +       extra_run_opts('+RTS -va -DI -RTS'),
    
    12 12
            grep_errmsg('table_name_'),
    
    13 13
            only_ways(debug_ways),
    
    14 14
            normalise_errmsg_fun(noCapabilityOutputFilter),
    
    ... ... @@ -24,7 +24,7 @@ test('ipeEventLog',
    24 24
     test('ipeEventLog_fromMap',
    
    25 25
          [ c_src,
    
    26 26
            extra_files(['ipe_lib.c', 'ipe_lib.h']),
    
    27
    -       extra_run_opts('+RTS -va -RTS'),
    
    27
    +       extra_run_opts('+RTS -va -DI -RTS'),
    
    28 28
            grep_errmsg('table_name_'),
    
    29 29
            only_ways(debug_ways),
    
    30 30
            normalise_errmsg_fun(noCapabilityOutputFilter),
    
    ... ... @@ -34,4 +34,3 @@ test('ipeEventLog_fromMap',
    34 34
            when(opsys('darwin'), fragile(0))
    
    35 35
          ],
    
    36 36
          compile_and_run, ['ipe_lib.c'])
    37
    -