summaryrefslogtreecommitdiff
path: root/compiler/utils
Commit message (Collapse)AuthorAgeFilesLines
* Remove dead `ncgDebugIsOn` and `NCG_DEBUG`John Ericson2019-09-111-8/+1
| | | | Haven't been used since 16206a6603e87e15d61c57456267c5f7ba68050e.
* Update FastString docstringsDaniel Gröber2019-09-091-8/+10
| | | | | | 1) FastStrings are always UTF-8 encoded now. 2) Clarify what is meant by "hashed" 3) Add mention of lazy z-enc
* Use lazyness for FastString's z-encoding memoizationDaniel Gröber2019-09-091-41/+37
| | | | | | | | | | | | | | | | | | | Having an IORef in FastString to memoize the z-encoded version is unecessary because there is this amazing thing Haskell can do natively, it's called "lazyness" :) We simply remove the UNPACK and strictness annotations from the constructor field corresponding to the z-encoding, making it lazy, and store the (pure) z-encoded string there. The only complication here is 'hasZEncoding' which allows cheking if a z-encoding was computed for a given string. Since this is only used for compiler performance statistics though it's not actually necessary to have the current per-string granularity. Instead I add a global IORef counter to the FastStringTable and use unsafePerformIO to increment the counter whenever a lazy z-encoding is forced.
* Fix GHC version guard for Int32Rep/Word32RepMoritz Kiefer2019-09-081-0/+4
| | | | | Those constructors have been added after GHC 8.8. The version guards in `binary` are correct, see https://github.com/kolmodin/binary/pull/167/files.
* Return results of Cmm streams in backendsÖmer Sinan Ağacan2019-08-281-2/+22
| | | | | | | | | | | | | | | | | | | This generalizes code generators (outputAsm, outputLlvm, outputC, and the call site codeOutput) so that they'll return the return values of the passed Cmm streams. This allows accumulating data during Cmm generation and returning it to the call site in HscMain. Previously the Cmm streams were assumed to return (), so the code generators returned () as well. This change is required by !1304 and !1530. Skipping CI as this was tested before and I only updated the commit message. [skip ci]
* Use variable length encoding for Binary instances.Andreas Klebinger2019-08-231-95/+246
| | | | | | | | Use LEB128 encoding for Int/Word variants. This reduces the size of interface files significantly. (~19%). Also includes a few small optimizations to make unboxing work better that I have noticed while looking at the core.
* Make non-streaming LLVM and C backends streamingÖmer Sinan Ağacan2019-08-231-1/+10
| | | | | | | | | This adds a Stream.consume function, uses it in LLVM and C code generators, and removes the use of Stream.collect function which was used to collect streaming Cmm generation results into a list. LLVM and C backends now properly use streamed Cmm generation, instead of collecting Cmm groups into a list before generating LLVM/C code.
* Remove Bag fold specialisations (#16969)Richard Lupton2019-08-191-29/+5
|
* Use Foldable instance of Bag for specialised Bag folds (#16969)Richard Lupton2019-08-191-19/+26
|
* Re-export foldlM and foldrM from Data.Foldable in MonadUtils (#16969)Richard Lupton2019-08-191-9/+1
|
* Generalized MonadUtils folds to Foldable (#16969)Richard Lupton2019-08-191-6/+5
|
* Faster exactLog2Sylvain Henry2019-08-181-14/+8
| | | | | | Make `exactLog2` faster (use `countLeadingZeros` and Int32 bit-ops). On my Core i7-9700k Criterion reports ~50% speedup (from 16 to 8ns).
* Rework the Binary Integer instance.Andreas Klebinger2019-08-141-22/+74
| | | | | | | | | | | | We used to serialise large integers as strings. Now they are serialized as a list of Bytes. This changes the size for a Integer in the higher 64bit range from 77 to 9 bytes when written to disk. The impact on the general case is small (<1% for interface files) as we don't use many Integers. But for code that uses many this should be a nice benefit.
* Add Foldable, Traversable instances for Uniq(D)FMSebastian Graf2019-08-132-4/+38
| | | | | The `UniqDFM` is deterministic, of course, while we provide an unsafe `NonDetUniqFM` wrapper for `UniqFM` to opt into nondeterministic instances.
* Add HasDebugCallStack to unionListsBen Gamari2019-07-181-1/+1
| | | | This should help identify a few cases where this is throwing warnings
* Create {Int,Word}32RepJohn Ericson2019-07-171-0/+4
| | | | | | | This prepares the way for making Int32# and Word32# the actual size they claim to be. Updates binary submodule for (de)serializing the new runtime reps.
* Expunge #ifdef and #ifndef from the codebaseJohn Ericson2019-07-141-1/+1
| | | | | | | | These are unexploded minds as far as the linter is concerned. I don't want to hit in my MRs by mistake! I did this with `sed`, and then rolled back some changes in the docs, config.guess, and the linter itself.
* Special case a few common patterns in unionLists.Andreas Klebinger2019-07-111-1/+10
| | | | | | | In particular we very often pass one empty list and in these cases we want to avoid the overhead of computing `xs ++ []`. This should fix #14759 and #16911.
* ghc-pkg needs settings file to un-hardcode target platformJohn Ericson2019-06-191-22/+0
| | | | This matches GHC itself getting the target platform from there.
* Move 'Platform' to ghc-bootJohn Ericson2019-06-193-192/+2
| | | | | | | 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.
* Remove dead codeKrzysztof Gogolewski2019-06-151-23/+0
|
* Add Outputable instances for Float, Double.Andreas Klebinger2019-06-131-0/+6
|
* Use DeriveFunctor throughout the codebase (#15654)Krzysztof Gogolewski2019-06-128-37/+17
|
* Refine the GHCI macro into HAVE[_{INTERNAL, EXTERNAL}]_INTERPRETERAlp Mestanogullari2019-06-111-1/+1
| | | | | | | | | | | | | | | | | As discussed in #16331, the GHCI macro, defined through 'ghci' flags in ghc.cabal.in, ghc-bin.cabal.in and ghci.cabal.in, is supposed to indicate whether GHC is built with support for an internal interpreter, that runs in the same process. It is however overloaded in a few places to mean "there is an interpreter available", regardless of whether it's an internal or external interpreter. For the sake of clarity and with the hope of more easily being able to build stage 1 GHCs with external interpreter support, this patch splits the previous GHCI macro into 3 different ones: - HAVE_INTERNAL_INTERPRETER: GHC is built with an internal interpreter - HAVE_EXTERNAL_INTERPRETER: GHC is built with support for external interpreters - HAVE_INTERPRETER: HAVE_INTERNAL_INTERPRETER || HAVE_EXTERNAL_INTERPRETER
* TmOracle: Replace negative term equalities by refutable PmAltConsSebastian Graf2019-06-071-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | The `PmExprEq` business was a huge hack and was at the same time vastly too powerful and not powerful enough to encode negative term equalities, i.e. facts of the form "forall y. x ≁ Just y". This patch introduces the concept of 'refutable shapes': What matters for the pattern match checker is being able to encode knowledge of the kind "x can no longer be the literal 5". We encode this knowledge in a `PmRefutEnv`, mapping a set of newly introduced `PmAltCon`s (which are just `PmLit`s at the moment) to each variable denoting above inequalities. So, say we have `x ≁ 42 ∈ refuts` in the term oracle context and try to solve an equality like `x ~ 42`. The entry in the refutable environment will immediately lead to a contradiction. This machinery renders the whole `PmExprEq` and `ComplexEq` business unnecessary, getting rid of a lot of (mostly dead) code. See the Note [Refutable shapes] in TmOracle for a place to start. Metric Decrease: T11195
* Break up `Settings` into smaller structsJohn Ericson2019-05-291-0/+28
| | | | | | | | | | | | | | | | | As far as I can tell, the fields within `Settings` aren't *intrinsicly* related. They just happen to be initialized the same way (in particular prior to the rest of `DynFlags`), and that is why they are grouped together. Within `Settings`, however, there are groups of settings that clearly do share something in common, regardless of how they anything is initialized. In the spirit of GHC being a library, where the end cosumer may choose to initialize this configuration in arbitrary ways, I made some new data types for thoses groups internal to `Settings`, and used them to define `Settings` instead. Hopefully this is a baby step towards a general decoupling of the stateful and stateless parts of GHC.
* Add hPutStringBuffer utilityDaniel Gröber2019-05-291-0/+6
|
* Fix missing unboxed tuple RuntimeReps (#16565)Krzysztof Gogolewski2019-05-291-7/+1
| | | | | | | | | | | | | Unboxed tuples and sums take extra RuntimeRep arguments, which must be manually passed in a few places. This was not done in deSugar/Check. This error was hidden because zipping functions in TyCoRep ignored lists with mismatching length. This is now fixed; the lengths are now checked by calling zipEqual. As suggested in #16565, I moved checking for isTyVar and isCoVar to zipTyEnv and zipCoEnv.
* Add a pprTraceWith functionSebastian Graf2019-05-271-3/+9
|
* Add PlainPanic for throwing exceptions without depending on pprintMichael Sloan2019-05-247-93/+174
| | | | | | | | | | | | | | | | | | | | | This commit splits out a subset of GhcException which do not depend on pretty printing (SDoc), as a new datatype called PlainGhcException. These exceptions can be caught as GhcException, because 'fromException' will convert them. The motivation for this change is that that the Panic module transitively depends on many modules, primarily due to pretty printing code. It's on the order of about 130 modules. This large set of dependencies has a few implications: 1. To avoid cycles / use of boot files, these dependencies cannot throw GhcException. 2. There are some utility modules that use UnboxedTuples and also use `panic`. This means that when loading GHC into GHCi, about 130 additional modules would need to be compiled instead of interpreted. Splitting the non-pprint exception throwing into a new module resolves this issue. See #13101
* Purge TargetPlatform_NAME and cTargetPlatformStringJohn Ericson2019-05-081-2/+2
|
* Add an Outputable instance for SDoc with ppr = id.klebinger.andreas@gmx.at2019-04-171-0/+4
| | | | When printf debugging this can be helpful.
* codegen: use newtype for Alignment in BasicTypesArtem Pyanykh2019-04-091-11/+0
|
* codegen: fix memset unroll for small bytearrays, add 64-bit setsArtem Pyanykh2019-04-091-0/+10
| | | | | | | | | | | | | | | | | | | | | | Fixes #16052 When the offset in `setByteArray#` is statically known, we can provide better alignment guarantees then just 1 byte. Also, memset can now do 64-bit wide sets. The current memset intrinsic is not optimal however and can be improved for the case when we know that we deal with (baseAddress at known alignment) + offset For instance, on 64-bit `setByteArray# s 1# 23# 0#` given that bytearray is 8 bytes aligned could be unrolled into `movb, movw, movl, movq, movq`; but currently it is `movb x23` since alignment of 1 is all we can embed into MO_Memset op.
* Remove unnecessary uses of UnboxedTuples pragma (see #13101 / #15454)Michael Sloan2019-04-011-1/+1
| | | | Also removes a couple unnecessary MagicHash pragmas
* Update Wiki URLs to point to GitLabTakenobu Tani2019-03-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This moves all URL references to Trac Wiki to their corresponding GitLab counterparts. This substitution is classified as follows: 1. Automated substitution using sed with Ben's mapping rule [1] Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy... New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy... 2. Manual substitution for URLs containing `#` index Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy...#Zzz New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy...#zzz 3. Manual substitution for strings starting with `Commentary` Old: Commentary/XxxYyy... New: commentary/xxx-yyy... See also !539 [1]: https://gitlab.haskell.org/bgamari/gitlab-migration/blob/master/wiki-mapping.json
* Replace nOfThem by replicateKrzysztof Gogolewski2019-03-191-4/+1
|
* compiler: Disable atomic renaming on WindowsBen Gamari2019-03-161-1/+13
| | | | | As discussed in #16450, this feature regresses CI on Windows, causing non-deterministic failures due to missing files.
* Update Trac ticket URLs to point to GitLabRyan Scott2019-03-153-4/+4
| | | | | This moves all URL references to Trac tickets to their corresponding GitLab counterparts.
* NCG: correctly escape path strings on Windows (#16389)Sylvain Henry2019-03-091-1/+11
| | | | | GHC native code generator generates .incbin and .file directives. We need to escape those strings correctly on Windows (see #16389).
* compiler: Refactor: extract `withAtomicRename`Niklas Hambüchen2019-03-091-1/+23
|
* Revert "compiler: Refactor: extract `withAtomicRename`"Ben Gamari2019-03-041-23/+1
| | | | This reverts commit e8a08f400744a860d1366c6680c8419d30f7cc2a.
* base: Allow fusion for zip7 and relatedAlexandre2019-02-241-35/+75
| | | | | | | | | | | | | | | | | | Fixes #14037. Metric Decrease: T9872b T9872d Reviewers: bgamari, simonpj, hvr Reviewed By: simonpj Subscribers: AndreasK, simonpj, osa1, dfeuer, rwbarton, carter GHC Trac Issues: #14037 Differential Revision: https://phabricator.haskell.org/D5249
* compiler: Refactor: extract `withAtomicRename`Niklas Hambüchen2019-02-211-1/+23
|
* Comments only, in GhcPreludeSimon Peyton Jones2019-02-201-1/+5
|
* Properly escape character literals in HaddocksAlec Theriault2019-02-151-4/+4
| | | | | | | | Character literals in Haddock should not be written as plain `'\n'` since single quotes are for linking identifiers. Besides, since we want the character literal to be monospaced, we really should use `@\'\\n\'@`. [skip ci]
* Make a smart mkAppTyMSimon Peyton Jones2019-02-142-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch finally delivers on Trac #15952. Specifically * Completely remove Note [The tcType invariant], along with its complicated consequences (IT1-IT6). * Replace Note [The well-kinded type invariant] with: Note [The Purely Kinded Type Invariant (PKTI)] * Instead, establish the (PKTI) in TcHsType.tcInferApps, by using a new function mkAppTyM when building a type application. See Note [mkAppTyM]. * As a result we can remove the delicate mkNakedXX functions entirely. Specifically, mkNakedCastTy retained lots of extremly delicate Refl coercions which just cluttered everything up, and(worse) were very vulnerable to being silently eliminated by (say) substTy. This led to a succession of bug reports. The result is noticeably simpler to explain, simpler to code, and Richard and I are much more confident that it is correct. It does not actually fix any bugs, but it brings us closer. E.g. I hoped it'd fix #15918 and #15799, but it doesn't quite do so. However, it makes it much easier to fix. I also did a raft of other minor refactorings: * Use tcTypeKind consistently in the type checker * Rename tcInstTyBinders to tcInvisibleTyBinders, and refactor it a bit * Refactor tcEqType, pickyEqType, tcEqTypeVis Simpler, probably more efficient. * Make zonkTcType zonk TcTyCons, at least if they have any free unification variables -- see zonk_tc_tycon in TcMType.zonkTcTypeMapper. Not zonking these TcTyCons was actually a bug before. * Simplify try_to_reduce_no_cache in TcFlatten (a lot) * Combine checkExpectedKind and checkExpectedKindX. And then combine the invisible-binder instantation code Much simpler now. * Fix a little bug in TcMType.skolemiseQuantifiedTyVar. I'm not sure how I came across this originally. * Fix a little bug in TyCoRep.isUnliftedRuntimeRep (the ASSERT was over-zealous). Again I'm not certain how I encountered this. * Add a missing solveLocalEqualities in TcHsType.tcHsPartialSigType. I came across this when trying to get level numbers right.
* Improve snocView implementation.klebinger.andreas@gmx.at2019-02-091-12/+17
| | | | | | | | | | | | The new implementation isn't tailrecursive and instead builds up the initial part of the list as it goes. This improves allocation numbers as we don't build up an intermediate list just to reverse it later. This is slightly slower for lists of size <= 3. But in benchmarks significantly faster for any list above 5 elements, assuming the majority of the resulting list will be evaluated.
* Replace a few uses of snocView with last/lastMaybe.klebinger.andreas@gmx.at2019-02-092-3/+12
| | | | | | These never used the first part of the result from snocView. Hence replacing them with last[Maybe] is both clearer and gives better performance.
* Replace BlockSequence with OrdList in BlockLayout.hsklebinger.andreas@gmx.at2019-01-311-1/+22
| | | | | OrdList does the same thing and more so there is no reason to have both.