summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* rts: Do not traverse nursery for dead closures in LDV profilewip/ldv-profileMatthew Pickering2019-06-261-23/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | It is important that `heapCensus` and `LdvCensusForDead` traverse the same areas. `heapCensus` increases the `not_used` counter which tracks how many closures are live but haven't been used yet. `LdvCensusForDead` increases the `void_total` counter which tracks how many dead closures there are. The `LAG` is then calculated by substracting the `void_total` from `not_used` and so it is essential that `not_used >= void_total`. This fact is checked by quite a few assertions. However, if a program has low maximum residency but allocates a lot in the nursery then these assertions were failing (see #16753 and #15903) because `LdvCensusForDead` was observing dead closures from the nursery which totalled more than the `not_used`. The same closures were not counted by `heapCensus`. Therefore, it seems that the correct fix is to make `LdvCensusForDead` agree with `heapCensus` and not traverse the nursery for dead closures. Fixes #16100 #16753 #15903 #8982
* rts: Correct assertion in LDV_recordDeadMatthew Pickering2019-06-261-1/+1
| | | | | It is possible that void_total is exactly equal to not_used and the other assertions for this check for <= rather than <.
* rts: Correct handling of LARGE ARR_WORDS in LDV profilerMatthew Pickering2019-06-263-19/+20
| | | | | | | | | This implements the correct fix for #11627 by skipping over the slop (which is zeroed) rather than adding special case logic for LARGE ARR_WORDS which runs the risk of not performing a correct census by ignoring any subsequent blocks. This approach implements similar logic to that in Sanity.c
* Remove unused UniqSupply functionsÖmer Sinan Ağacan2019-06-251-42/+1
|
* testsuite: Unbreak T16608 testsBen Gamari2019-06-252-2/+4
| | | | | Sleep to avoid non-determinism due to Darwin's poor mtime resolution. Fixes #16855.
* Don't eta-expand unsaturated primopsBen Gamari2019-06-2510-35/+134
| | | | | | | | | | | Previously, as described in Note [Primop wrappers], `hasNoBinding` would return False in the case of `PrimOpId`s. This would result in eta expansion of unsaturated primop applications during CorePrep. Not only did this expansion result in unnecessary allocations, but it also meant lead to rather nasty inconsistencies between the CAFfy-ness determinations made by TidyPgm and CorePrep. This fixes #16846.
* CoreToStg: Enable CAFfyness checking with -dstg-lintBen Gamari2019-06-251-2/+11
| | | | | The debugging involved in finding #16846 wouldn't have been necessary had the consistentCafInfo check been enabled. However, :wq
* testsuite: Add test for #16846Ben Gamari2019-06-253-0/+42
|
* [skip ci] Typo fix: b*ar*nches -> b*ra*nchesSiddharth Bhat2019-06-251-1/+1
|
* testsuite: Mark ghci058 as broken on WindowsBen Gamari2019-06-251-1/+2
| | | | Due to #16858.
* testsuite: Fix expected output for caf_crashBen Gamari2019-06-251-0/+1
|
* testsuite: Don't run T16525a with -DS unless compiler_debuggedBen Gamari2019-06-251-1/+2
| | | | | | Originally I was thinking of just skipping the test unless compiled_debugged==True. However, the test will likely be useful even without -DS, so let's run it either way.
* gitlab-ci: Add testsuite typechecking lintBen Gamari2019-06-251-0/+13
|
* testsuite: Fix a few issues in JUnit outputBen Gamari2019-06-251-5/+14
| | | | | | | * Make it pass mypy * Fix a typo in test name field * Report more stderr output * Report stdout output
* testsuite: A major revamp of the driverBen Gamari2019-06-259-357/+523
| | | | | | | | | This tries to put the testsuite driver into a slightly more maintainable condition: * Add type annotations where easily done * Use pathlib.Path instead of str paths * Make it pass the mypy typechecker
* Simplify link_caf and mkForeignLabel functionsÖmer Sinan Ağacan2019-06-252-5/+3
|
* Fix cyclic dependencies when using --configureAndrey Mokhov2019-06-2521-105/+77
| | | | | | | | | | | This resolves #16809 (https://gitlab.haskell.org/ghc/ghc/issues/16809). This patch removes the unnecessary dependency on configure-generated flags `windowsHost`, `osxHost` and `iosHost`, using the information provided by the module `System.Info` instead. We also take care to use the `CrossCompiling` flag generated by the configure script only after the latter had a chance to run.
* Add MonadFail instance for ParserMErik de Castro Lopo2019-06-241-0/+11
|
* Fixes for LLVM 7Erik de Castro Lopo2019-06-245-12/+26
| | | | | | | LLVM version numberinf changed recently. Previously, releases were numbered 4.0, 5.0 and 6.0 but with version 7, they dropped the redundant ".0". Fix requires for Llvm detection and some code.
* Refactor UnliftedNewtypes-relation kind signature validity checksRyan Scott2019-06-2317-67/+220
| | | | | | | | | | | | | | | | | | | | | This fixes three infelicities related to the programs that are (and aren't) accepted with `UnliftedNewtypes`: * Enabling `UnliftedNewtypes` would permit newtypes to have return kind `Id Type`, which had disastrous results (i.e., GHC panics). * Data family declarations ending in kind `TYPE r` (for some `r`) weren't being accepted if `UnliftedNewtypes` wasn't enabled, despite the GHC proposal specifying otherwise. * GHC wasn't warning about programs that _would_ typecheck if `UnliftedNewtypes` were enabled in certain common cases. As part of fixing these issues, I factored out the logic for checking all of the various properties about data type/data family return kinds into a single `checkDataKindSig` function. I also cleaned up some of the formatting in the existing error message that gets thrown. Fixes #16821, fixes #16827, and fixes #16829.
* ghci: Load static objects in batchesBen Gamari2019-06-231-13/+31
| | | | | | | | | | | | Previously in the case where GHC was dynamically linked we would load static objects one-by-one by linking each into its own shared object and dlopen'ing each in order. However, this meant that the link would fail in the event that the objects had cyclic symbol dependencies. Here we fix this by merging each "run" of static objects into a single shared object and loading this. Fixes #13786 for the case where GHC is dynamically linked.
* testsuite: Test for #13786Ben Gamari2019-06-237-0/+51
|
* testsuite: Add caf_crash testcaseBen Gamari2019-06-226-0/+67
|
* rts: Reset STATIC_LINK field of reverted CAFsBen Gamari2019-06-221-6/+11
| | | | | | | | | | | | When we revert a CAF we must reset the STATIC_LINK field lest the GC might ignore the CAF (e.g. as it carries the STATIC_FLAG_LIST flag) and will consequently overlook references to object code that we are trying to unload. This would result in the reachable object code being unloaded. See Note [CAF lists] and Note [STATIC_LINK fields]. This fixes #16842. Idea-due-to: Phuong Trinh <lolotp@fb.com>
* testsuite: Mark T5611 as broken in ghci wayBen Gamari2019-06-221-1/+4
| | | | As described in #16845.
* testsuite: Add test for #16563Ben Gamari2019-06-223-0/+4
|
* ghci: Don't rely on resolution of System.IO to base moduleBen Gamari2019-06-2213-36/+79
| | | | | | | | | Previously we would hackily evaluate a textual code snippet to compute actions to disable I/O buffering and flush the stdout/stderr handles. This broke in a number of ways (#15336, #16563). Instead we now ship a module (`GHC.GHCi.Helpers`) with `base` containing the needed actions. We can then easily refer to these via `Orig` names.
* testsuite: Mark T16608_* as fragile on DarwinBen Gamari2019-06-221-2/+2
| | | | As noted in #16855.
* linker: Disable code unloadingBen Gamari2019-06-211-1/+5
| | | | | | | | | As noted in #16841, there are currently a variety of bugs in the unloading logic. These only affect Windows since code unloading is disabled on Linux, where we build with `GhcDynamic=YES` by default. In the interest of getting the tree green on Windows disable code unloading until the issues are resolved.
* testsuite: Mark T15633a and T15633b as fragile on WindowsBen Gamari2019-06-211-2/+2
| | | | As noted in #16813, these tests seem to be fragile on Windows.
* testsuite: Mark T7702 as broken on WindowsBen Gamari2019-06-211-0/+1
| | | | Due to #16799.
* testsuite: Mark T7170 as broken on WindowsBen Gamari2019-06-211-1/+4
| | | | Due to #16801.
* testsuite: Mark OldModLocation as broken on WindowsBen Gamari2019-06-211-0/+1
| | | | | | | | | | | Strangely the path it emits contains duplicate path delimiters (#16772), ```patch --- ghc-api/downsweep/OldModLocation.run/OldModLocation.stderr.normalised 2019-06-04 14:40:26.326075000 +0000 +++ ghc-api/downsweep/OldModLocation.run/OldModLocation.run.stderr.normalised 2019-06-04 14:40:26.328029200 +0000 @@ -1 +1 @@ -[Just "A.hs",Just "mydir/B.hs"] +[Just "A.hs",Just "mydir//B.hs"] ```
* testsuite: Add stderr output for UnsafeInfered02 on WindowsBen Gamari2019-06-211-0/+7
| | | | | | | | | | | | | | | | | | | | | | | This test uses TemplateHaskell causing GHC to build dynamic objects on platforms where dynamic linking is available. However, Windows doesn't support dynamic linking. Consequently the test would fail on Windows with: ```patch --- safeHaskell/safeInfered/UnsafeInfered02.run/UnsafeInfered02.stderr.normalised 2019-06-04 15:10:10.521594200 +0000 +++ safeHaskell/safeInfered/UnsafeInfered02.run/UnsafeInfered02.comp.stderr.normalised 2019-06-04 15:10:10.523546200 +0000 @@ -1,5 +1,5 @@ -[1 of 2] Compiling UnsafeInfered02_A ( UnsafeInfered02_A.hs, UnsafeInfered02_A.o, UnsafeInfered02_A.dyn_o ) -[2 of 2] Compiling UnsafeInfered02 ( UnsafeInfered02.hs, UnsafeInfered02.o, UnsafeInfered02.dyn_o ) +[1 of 2] Compiling UnsafeInfered02_A ( UnsafeInfered02_A.hs, UnsafeInfered02_A.o ) +[2 of 2] Compiling UnsafeInfered02 ( UnsafeInfered02.hs, UnsafeInfered02.o ) UnsafeInfered02.hs:4:1: UnsafeInfered02_A: Can't be safely imported! ``` The other approach I considered for this issue is to pass `-v0` to GHC. However, I felt we should probably do this consistently for all of the tests in this directory and this would take more time than I currently have.
* testsuite: Mark T3372 as fragile on WindowsBen Gamari2019-06-212-1/+9
| | | | | | | | On Windows we must lock package databases even when opening for read-only access. This means that concurrent GHC sessions are very likely to fail with file lock contention. See #16773.
* testsuite: Skip dynamicToo006 when dynamic linking is not availableBen Gamari2019-06-211-1/+2
| | | | This was previously failling on Windows.
* Add HoleFitPlugins and RawHoleFitswip/D5373Matthías Páll Gissurarson2019-06-2117-164/+864
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a new kind of plugin, Hole fit plugins. These plugins can change what candidates are considered when looking for valid hole fits, and add hole fits of their own. The type of a plugin is relatively simple, ``` type FitPlugin = TypedHole -> [HoleFit] -> TcM [HoleFit] type CandPlugin = TypedHole -> [HoleFitCandidate] -> TcM [HoleFitCandidate] data HoleFitPlugin = HoleFitPlugin { candPlugin :: CandPlugin , fitPlugin :: FitPlugin } data TypedHole = TyH { tyHRelevantCts :: Cts -- ^ Any relevant Cts to the hole , tyHImplics :: [Implication] -- ^ The nested implications of the hole with the -- innermost implication first. , tyHCt :: Maybe Ct -- ^ The hole constraint itself, if available. } This allows users and plugin writers to interact with the candidates and fits as they wish, even going as far as to allow them to reimplement the current functionality (since `TypedHole` contains all the relevant information). As an example, consider the following plugin: ``` module HolePlugin where import GhcPlugins import TcHoleErrors import Data.List (intersect, stripPrefix) import RdrName (importSpecModule) import TcRnTypes import System.Process plugin :: Plugin plugin = defaultPlugin { holeFitPlugin = hfp, pluginRecompile = purePlugin } hfp :: [CommandLineOption] -> Maybe HoleFitPluginR hfp opts = Just (fromPureHFPlugin $ HoleFitPlugin (candP opts) (fp opts)) toFilter :: Maybe String -> Maybe String toFilter = flip (>>=) (stripPrefix "_module_") replace :: Eq a => a -> a -> [a] -> [a] replace match repl str = replace' [] str where replace' sofar (x:xs) | x == match = replace' (repl:sofar) xs replace' sofar (x:xs) = replace' (x:sofar) xs replace' sofar [] = reverse sofar -- | This candidate plugin filters the candidates by module, -- using the name of the hole as module to search in candP :: [CommandLineOption] -> CandPlugin candP _ hole cands = do let he = case tyHCt hole of Just (CHoleCan _ h) -> Just (occNameString $ holeOcc h) _ -> Nothing case toFilter he of Just undscModName -> do let replaced = replace '_' '.' undscModName let res = filter (greNotInOpts [replaced]) cands return $ res _ -> return cands where greNotInOpts opts (GreHFCand gre) = not $ null $ intersect (inScopeVia gre) opts greNotInOpts _ _ = True inScopeVia = map (moduleNameString . importSpecModule) . gre_imp -- Yes, it's pretty hacky, but it is just an example :) searchHoogle :: String -> IO [String] searchHoogle ty = lines <$> (readProcess "hoogle" [(show ty)] []) fp :: [CommandLineOption] -> FitPlugin fp ("hoogle":[]) hole hfs = do dflags <- getDynFlags let tyString = showSDoc dflags . ppr . ctPred <$> tyHCt hole res <- case tyString of Just ty -> liftIO $ searchHoogle ty _ -> return [] return $ (take 2 $ map (RawHoleFit . text . ("Hoogle says: " ++)) res) ++ hfs fp _ _ hfs = return hfs ``` with this plugin available, you can compile the following file ``` {-# OPTIONS -fplugin=HolePlugin -fplugin-opt=HolePlugin:hoogle #-} module Main where import Prelude hiding (head, last) import Data.List (head, last) t :: [Int] -> Int t = _module_Prelude g :: [Int] -> Int g = _module_Data_List main :: IO () main = print $ t [1,2,3] ``` and get the following output: ``` Main.hs:14:5: error: • Found hole: _module_Prelude :: [Int] -> Int Or perhaps ‘_module_Prelude’ is mis-spelled, or not in scope • In the expression: _module_Prelude In an equation for ‘t’: t = _module_Prelude • Relevant bindings include t :: [Int] -> Int (bound at Main.hs:14:1) Valid hole fits include Hoogle says: GHC.List length :: [a] -> Int Hoogle says: GHC.OldList length :: [a] -> Int t :: [Int] -> Int (bound at Main.hs:14:1) g :: [Int] -> Int (bound at Main.hs:17:1) length :: forall (t :: * -> *) a. Foldable t => t a -> Int with length @[] @Int (imported from ‘Prelude’ at Main.hs:5:1-34 (and originally defined in ‘Data.Foldable’)) maximum :: forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a with maximum @[] @Int (imported from ‘Prelude’ at Main.hs:5:1-34 (and originally defined in ‘Data.Foldable’)) (Some hole fits suppressed; use -fmax-valid-hole-fits=N or -fno-max-valid-hole-fits) | 14 | t = _module_Prelude | ^^^^^^^^^^^^^^^ Main.hs:17:5: error: • Found hole: _module_Data_List :: [Int] -> Int Or perhaps ‘_module_Data_List’ is mis-spelled, or not in scope • In the expression: _module_Data_List In an equation for ‘g’: g = _module_Data_List • Relevant bindings include g :: [Int] -> Int (bound at Main.hs:17:1) Valid hole fits include Hoogle says: GHC.List length :: [a] -> Int Hoogle says: GHC.OldList length :: [a] -> Int g :: [Int] -> Int (bound at Main.hs:17:1) head :: forall a. [a] -> a with head @Int (imported from ‘Data.List’ at Main.hs:7:19-22 (and originally defined in ‘GHC.List’)) last :: forall a. [a] -> a with last @Int (imported from ‘Data.List’ at Main.hs:7:25-28 (and originally defined in ‘GHC.List’)) | 17 | g = _module_Data_List ``` This relatively simple plugin has two functions, as an example of what is possible to do with hole fit plugins. The candidate plugin starts by filtering the candidates considered by module, indicated by the name of the hole (`_module_Data_List`). The second function is in the fit plugin, where the plugin invokes a local hoogle instance to search by the type of the hole. By adding the `RawHoleFit` type, we can also allow these completely free suggestions, used in the plugin above to display fits found by Hoogle. Additionally, the `HoleFitPluginR` wrapper can be used for plugins to maintain state between invocations, which can be used to speed up invocation of plugins that have expensive initialization. ``` -- | HoleFitPluginR adds a TcRef to hole fit plugins so that plugins can -- track internal state. Note the existential quantification, ensuring that -- the state cannot be modified from outside the plugin. data HoleFitPluginR = forall s. HoleFitPluginR { hfPluginInit :: TcM (TcRef s) -- ^ Initializes the TcRef to be passed to the plugin , hfPluginRun :: TcRef s -> HoleFitPlugin -- ^ The function defining the plugin itself , hfPluginStop :: TcRef s -> TcM () -- ^ Cleanup of state, guaranteed to be called even on error } ``` Of course, the syntax here is up for debate, but hole fit plugins allow us to experiment relatively easily with ways to interact with typed-holes without having to dig deep into GHC. Reviewers: bgamari Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5373
* users-guide: Update -Wsafe description for #16689Ben Gamari2019-06-191-1/+2
| | | | | We no longer emit a warning when a safe module is explicitly declared as such.
* users-guide: Fix a variety of broken links and syntaxBen Gamari2019-06-195-19/+30
|
* ghc-pkg needs settings file to un-hardcode target platformJohn Ericson2019-06-1910-84/+182
| | | | This matches GHC itself getting the target platform from there.
* Add 'stringEncodeArch' and 'stringEncodeOS' to GHC.PlatformJohn Ericson2019-06-191-0/+61
|
* Move 'Platform' to ghc-bootJohn Ericson2019-06-1983-83/+83
| | | | | | | ghc-pkg needs to be aware of platforms so it can figure out which subdire within the user package db to use. This is admittedly roundabout, but maybe Cabal could use the same notion of a platform as GHC to good affect too.
* Comments and tiny refactorSimon Peyton Jones2019-06-193-24/+33
| | | | | | | | | | | * Added Note [Quantified varaibles in partial type signatures] in TcRnTypes * Kill dVarSetElemsWellScoped; it was only called in one function, quantifyTyVars. I inlined it because it was only scopedSort . dVarSetElems * Kill Type.tyCoVarsOfBindersWellScoped, never called.
* Fix typechecking of partial type signaturesSimon Peyton Jones2019-06-1918-124/+215
| | | | | | | | | | | | | | | | | | | | | | | | | | | Partial type sigs had grown hair. tcHsParialSigType was doing lots of unnecessary work, and tcInstSig was cloning it unnecessarily -- and the result didn't even work: #16728. This patch cleans it all up, described by TcHsType Note [Checking parital type signatures] I basically just deleted code... but very carefully! Some refactoring along the way * Distinguish more explicintly between "anonymous" wildcards "_" and "named" wildcards "_a". I changed the names of a number of functions to make this distinction much more apparent. The patch also revealed that the code in `TcExpr` that implements the special typing rule for `($)` was wrong. It called `getRuntimeRep` in a situation where where was no particular reason to suppose that the thing had kind `TYPE r`. This caused a crash in typecheck/should_run/T10846. The fix was easy, and actually simplifies the code in `TcExpr` quite a bit. Hooray.
* Fix two places that failed the substitution invariantSimon Peyton Jones2019-06-192-6/+5
| | | | | | | | | The substition invariant relies on keeping the in-scope set in sync, and we weren't always doing so, which means that a DEBUG compiler crashes sometimes with an assertion failure This patch fixes a couple more cases. Still not validate clean (with -DEEBUG) but closer!
* Fix #1620: ModBreaks.modBreaks_array not initialisedRoland Senn2019-06-195-7/+45
| | | | | | | | | After a :cd command and after setting some package flags, GHCi unloads all loaded modules by resetting the list of targets. This patch deletes eventually defined debugger breakpoints, before GHCi resets the target list. The common code is factored out into the new function clearAllTargets.
* Properly trim IdInfos of DFunIds and PatSyns in TidyPgmÖmer Sinan Ağacan2019-06-1912-133/+184
| | | | | | | | | | | Not doing this right caused #16608. We now properly trim IdInfos of DFunIds and PatSyns. Some further refactoring done by SPJ. Two regression tests T16608_1 and T16608_2 added. Fixes #16608
* Fix a Note name in CmmNodeÖmer Sinan Ağacan2019-06-191-1/+1
| | | | | | ("Continuation BlockIds" is referenced in CmmProcPoint) [skip ci]
* Make sure mkSplitUniqSupply stores the precomputed mask only.Andreas Klebinger2019-06-183-1/+27
| | | | | | | | | | | | | | | | | | | | mkSplitUniqSupply was lazy on the boxed char. This caused a bunch of issues: * The closure captured the boxed Char * The mask was recomputed on every split of the supply. * It also caused the allocation of MkSplitSupply to happen in it's own (allocated) closure. The reason of which I did not further investigate. We know force the computation of the mask inside mkSplitUniqSupply. * This way the mask is computed at most once per UniqSupply creation. * It allows ww to kick in, causing the closure to retain the unboxed value. Requesting Uniques in a loop is now faster by about 20%. I did not check the impact on the overall compiler, but I added a test to avoid regressions.
* gitlab-ci: Run alpine builds during nightly jobBen Gamari2019-06-181-3/+12
|