1. 27 Jan, 2009 1 commit
  2. 02 Jan, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Make record selectors into ordinary functions · 9ffadf21
      simonpj@microsoft.com authored
      This biggish patch addresses Trac #2670.  The main effect is to make
      record selectors into ordinary functions, whose unfoldings appear in
      interface files, in contrast to their previous existence as magic
      "implicit Ids".  This means that the usual machinery of optimisation,
      analysis, and inlining applies to them, which was failing before when
      the selector was somewhat complicated.  (Which it can be when
      strictness annotations, unboxing annotations, and GADTs are involved.)
      
      The change involves the following points
      
      * Changes in Var.lhs to the representation of Var.  Now a LocalId can
        have an IdDetails as well as a GlobalId.  In particular, the
        information that an Id is a record selector is kept in the
        IdDetails.  While compiling the current module, the record selector
        *must* be a LocalId, so that it participates properly in compilation
        (free variables etc).
      
        This led me to change the (hidden) representation of Var, so that there
        is now only one constructor for Id, not two.
      
      * The IdDetails is persisted into interface files, so that an
        importing module can see which Ids are records selectors.
      
      * In TcTyClDecls, we generate the record-selector bindings in renamed,
        but not typechecked form.  In this way, we can get the typechecker
        to add all the types and so on, which is jolly helpful especially
        when GADTs or type families are involved.  Just like derived
        instance declarations.
      
        This is the big new chunk of 180 lines of code (much of which is
        commentary).  A call to the same function, mkAuxBinds, is needed in
        TcInstDcls for associated types.
      
      * The typechecker therefore has to pin the correct IdDetails on to 
        the record selector, when it typechecks it.  There was a neat way
        to do this, by adding a new sort of signature to HsBinds.Sig, namely
        IdSig.  This contains an Id (with the correct Name, Type, and IdDetails);
        the type checker uses it as the binder for the final binding.  This
        worked out rather easily.
      
      * Record selectors are no longer "implicit ids", which entails changes to
           IfaceSyn.ifaceDeclSubBndrs
           HscTypes.implicitTyThings
           TidyPgm.getImplicitBinds
        (These three functions must agree.)
      
      * MkId.mkRecordSelectorId is deleted entirely, some 300+ lines (incl
        comments) of very error prone code.  Happy days.
      
      * A TyCon no longer contains the list of record selectors: 
        algTcSelIds is gone
      
      The renamer is unaffected, including the way that import and export of
      record selectors is handled.
      
      Other small things
      
      * IfaceSyn.ifaceDeclSubBndrs had a fragile test for whether a data
        constructor had a wrapper.  I've replaced that with an explicit flag
        in the interface file. More robust I hope.
      
      * I renamed isIdVar to isId, which touched a few otherwise-unrelated files.
      
      9ffadf21
  3. 02 Dec, 2008 2 commits
  4. 28 Nov, 2008 2 commits
    • Thomas Schilling's avatar
    • Thomas Schilling's avatar
      Use a per-session data structure for callbacks. Make 'WarnErrLogger' · 9a4607c3
      Thomas Schilling authored
      part of it.
      
      Part of the GHC API essentially represents a compilation framework.
      The difference of a *framework* as opposed to a *library* is that the
      overall structure of the functionality is pre-defined but certain
      details can be customised via callbacks.  (Also known as the Hollywood
      Principle: "Don't call us, we'll call you.")
      
      This patch introduces a per-session data structure that contains all
      the callbacks instead of adding lots of small function arguments
      whenever we want to give the user more control over certain parts of
      the API.  This should also help with future changes: Adding a new
      callback doesn't break old code since code that doesn't know about the
      new callback will use the (hopefully sane) default implementation.
      
      Overall, however, we should try and keep the number of callbacks small
      and well-defined (and provide useful defaults) and use simple library
      routines for the rest.
      9a4607c3
  5. 26 Nov, 2008 1 commit
    • Thomas Schilling's avatar
      Force recompilation of BCOs when they were compiled in HscNothing mode. · 5e0453ca
      Thomas Schilling authored
      Previously, loading a set of modules in HscNothing mode and then
      switching to HscInterpreted could lead to crashes since modules
      compiled with HscNothing were thought to be valid bytecode objects.
      
      This patch forces recompilation in these cases, hence switching between
      HscNothing and HscInterpreted should be safe now.
      5e0453ca
  6. 25 Nov, 2008 1 commit
    • Thomas Schilling's avatar
      Major clean-up of HscMain. · e06951a7
      Thomas Schilling authored
      This patch entails a major restructuring of HscMain and a small bugfix
      to MkIface (which required the restructuring in HscMain).
      
      In MkIface:
      
        - mkIface* no longer outputs orphan warnings directly and also no
          longer quits GHC when -Werror is set.  Instead, errors are
          reported using the common IO (Messages, Maybe result) scheme.
      
      In HscMain:
      
        - Get rid of the 'Comp' monad.  This monad was mostly GhcMonad + two
          reader arguments, a ModSummary for the currently compiled module
          and a possible old interface.  The latter actually lead to a small
          space-leak since only its hash was needed (to check whether the
          newly-generated interface file was the same as the original one).
      
          Functions originally of type 'Comp' now only take the arguments
          that they actually need.  This leads to slighly longer argument
          lists in some places, however, it is now much easier to see what
          is actually going on.
      
        - Get rid of 'myParseModule'.  Rename 'parseFile' to 'hscParse'.
      
        - Join 'deSugarModule' and 'hscDesugar' (keeping the latter).
      
        - Rename 'typecheck{Rename}Module{'}' to 'hscTypecheck{Rename}'.
          One variant keeps the renamed syntax, the other doesn't.
      
        - Parameterise 'HscStatus', so that 'InteractiveStatus' is just a
          different parameterisation of 'HscStatus'.
      
        - 'hscCompile{OneShot,Batch,Nothing,Interactive}' are now
          implemented using a (local) typeclass called 'HsCompiler'.  The
          idea is to make the common structure more obvious.  Using this
          typeclass we now have two functions 'genericHscCompile' (original
          'hscCompiler') and 'genericHscRecompile' (original 'genComp')
          describing the default pipeline.  The methods of the typeclass
          describe a sort of "hook" interface (in OO-terms this would be
          called the "template method" pattern).
      
          One problem with this approach is that we parameterise over the
          /result/ type which, in fact, is not actually different for
          "nothing" and "batch" mode.  To avoid functional dependencies or
          associated types, we use type tags to make them artificially
          different and parameterise the type class over the result type.
          A perhaps better approach might be to use records instead.
          
        - Drop some redundant 'HscEnv' arguments.  These were likely
          different from what 'getSession' would return because during
          compilation we temporarily set the module's DynFlags as well as a
          few other fields.  We now use the 'withTempSession' combinator to
          temporarily change the 'HscEnv' and automatically restore the
          original session after the enclosed action has returned (even in
          case of exceptions).
      
        - Rename 'hscCompile' to 'hscGenHardCode' (since that is what it
          does).
      
      Calls in 'GHC' and 'DriverPipeline' accordingly needed small
      adaptions.
      e06951a7
  7. 22 Nov, 2008 1 commit
  8. 28 Oct, 2008 1 commit
  9. 30 Oct, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Add (a) CoreM monad, (b) new Annotations feature · 9bcd95ba
      simonpj@microsoft.com authored
      This patch, written by Max Bolingbroke,  does two things
      
      1.  It adds a new CoreM monad (defined in simplCore/CoreMonad),
          which is used as the top-level monad for all the Core-to-Core
          transformations (starting at SimplCore).  It supports
             * I/O (for debug printing)
             * Unique supply
             * Statistics gathering
             * Access to the HscEnv, RuleBase, Annotations, Module
          The patch therefore refactors the top "skin" of every Core-to-Core
          pass, but does not change their functionality.
      
      2.  It adds a completely new facility to GHC: Core "annotations".
          The idea is that you can say
             {#- ANN foo (Just "Hello") #-}
          which adds the annotation (Just "Hello") to the top level function
          foo.  These annotations can be looked up in any Core-to-Core pass,
          and are persisted into interface files.  (Hence a Core-to-Core pass
          can also query the annotations of imported things.)  Furthermore,
          a Core-to-Core pass can add new annotations (eg strictness info)
          of its own, which can be queried by importing modules.
      
      The design of the annotation system is somewhat in flux.  It's
      designed to work with the (upcoming) dynamic plug-ins mechanism,
      but is meanwhile independently useful.
      
      Do not merge to 6.10!  
      9bcd95ba
  10. 14 Oct, 2008 1 commit
  11. 10 Oct, 2008 1 commit
  12. 06 Oct, 2008 2 commits
  13. 03 Oct, 2008 2 commits
  14. 18 Sep, 2008 1 commit
    • pepe's avatar
      Fix a couple of issues with :print · decbb181
      pepe authored
            
            - Ticket #1995: Unsoundness with newtypes
            - Ticket #2475: "Can't unify" error when stopped at an exception
            
            In addition this patch adds the following:
            
            - Unfailingness: RTTI cannot panic anymore. 
              In case of failure, it recovers gracefully by returning the "I know nothing" type
            - A -ddump-rtti flag
      decbb181
  15. 14 Sep, 2008 1 commit
  16. 27 Aug, 2008 1 commit
    • Simon Marlow's avatar
      re-fix of #1205, fix #2542 · 3d73e45b
      Simon Marlow authored
      New form of :load in GHCi:
      
      > :load *A
      
      forces A to be loaded as byte-code.  See the manual for details.  The
      previous behaviour for specifying filenames vs. module names on the
      command line and in :load has been restored.
      
      The Target datatype has a new Bool field, which is True if the target
      is allowed to be loaded from compiled code, or False otherwise, so
      this functionality is available via the GHC API.  guessTarget
      understands the *-prefix form for specifying targets.
      3d73e45b
  17. 07 Aug, 2008 1 commit
  18. 31 Jul, 2008 2 commits
  19. 20 Jul, 2008 2 commits
  20. 30 May, 2008 1 commit
    • Simon Marlow's avatar
      Fix a bug to do with recursive modules in one-shot mode · d83e1ac4
      Simon Marlow authored
      The problem was that when loading interface files in checkOldIface, we
      were not passing the If monad the mutable variable for use when
      looking up entities in the *current* module, with the result that the
      knots wouldn't be tied properly, and some instances of TyCons would
      be incorrectly abstract.
      
      This bug has subtle effects: for example, recompiling a module without
      making any changes might lead to a slightly different result (noticed
      due to the new interface-file fingerprints).  The bug doesn't lead to
      any direct failures that we're aware of.
      d83e1ac4
  21. 29 May, 2008 1 commit
    • dias@eecs.harvard.edu's avatar
      Cmm back end upgrades · 25628e27
      dias@eecs.harvard.edu authored
      Several changes in this patch, partially bug fixes, partially new code:
      o bug fixes in ZipDataflow
         - added some checks to verify that facts converge
         - removed some erroneous checks of convergence on entry nodes
         - added some missing applications of transfer functions
      o changed dataflow clients to use ZipDataflow, making ZipDataflow0 obsolete
      o eliminated DFA monad (no need for separate analysis and rewriting monads with ZipDataflow)
      o started stack layout changes
         - no longer generating CopyIn and CopyOut nodes (not yet fully expunged though)
         - still not using proper calling conventions
      o simple new optimizations:
         - common block elimination
            -- have not yet tried to move the Adams opt out of CmmProcPointZ
         - block concatenation
      o piped optimization fuel up to the HscEnv
         - can be limited by a command-line flag
         - not tested, and probably not yet properly used by clients
      o added unique supply to FuelMonad, also lifted unique supply to DFMonad
      25628e27
  22. 28 May, 2008 1 commit
    • Simon Marlow's avatar
      Use MD5 checksums for recompilation checking (fixes #1372, #1959) · 526c3af1
      Simon Marlow authored
      This is a much more robust way to do recompilation checking.  The idea
      is to create a fingerprint of the ABI of an interface, and track
      dependencies by recording the fingerprints of ABIs that a module
      depends on.  If any of those ABIs have changed, then we need to
      recompile.
      
      In bug #1372 we weren't recording dependencies on package modules,
      this patch fixes that by recording fingerprints of package modules
      that we depend on.  Within a package there is still fine-grained
      recompilation avoidance as before.
      
      We currently use MD5 for fingerprints, being a good compromise between
      efficiency and security.  We're not worried about attackers, but we
      are worried about accidental collisions.
      
      All the MD5 sums do make interface files a bit bigger, but compile
      times on the whole are about the same as before.  Recompilation
      avoidance should be a bit more accurate than in 6.8.2 due to fixing
      #1959, especially when using -O.
      526c3af1
  23. 12 Apr, 2008 1 commit
  24. 02 Apr, 2008 1 commit
    • Simon Marlow's avatar
      Do not #include external header files when compiling via C · c245355e
      Simon Marlow authored
      This has several advantages:
      
       - -fvia-C is consistent with -fasm with respect to FFI declarations:
         both bind to the ABI, not the API.
      
       - foreign calls can now be inlined freely across module boundaries, since
         a header file is not required when compiling the call.
      
       - bootstrapping via C will be more reliable, because this difference
         in behavour between the two backends has been removed.
      
      There is one disadvantage:
      
       - we get no checking by the C compiler that the FFI declaration
         is correct.
      
      So now, the c-includes field in a .cabal file is always ignored by
      GHC, as are header files specified in an FFI declaration.  This was
      previously the case only for -fasm compilations, now it is also the
      case for -fvia-C too.
      c245355e
  25. 29 Mar, 2008 1 commit
  26. 07 Feb, 2008 1 commit
    • Ian Lynagh's avatar
      Convert more UniqFM's back to LazyUniqFM's · d51f42f6
      Ian Lynagh authored
      These fix these failures:
         break008(ghci)
         break009(ghci)
         break026(ghci)
         ghci.prog009(ghci)
         ghci025(ghci)
         print007(ghci)
         prog001(ghci)
         prog002(ghci)
         prog003(ghci)
      at least some of which have this symptom:
          Exception: expectJust prune
      d51f42f6
  27. 17 Jan, 2008 1 commit
  28. 20 Jan, 2008 1 commit
  29. 17 Jan, 2008 1 commit
    • Isaac Dupree's avatar
      lots of portability changes (#1405) · 206b4dec
      Isaac Dupree authored
      re-recording to avoid new conflicts was too hard, so I just put it
      all in one big patch :-(  (besides, some of the changes depended on
      each other.)  Here are what the component patches were:
      
      Fri Dec 28 11:02:55 EST 2007  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * document BreakArray better
      
      Fri Dec 28 11:39:22 EST 2007  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * properly ifdef BreakArray for GHCI
      
      Fri Jan  4 13:50:41 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * change ifs on __GLASGOW_HASKELL__ to account for... (#1405)
        for it not being defined. I assume it being undefined implies
        a compiler with relatively modern libraries but without most
        unportable glasgow extensions.
      
      Fri Jan  4 14:21:21 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * MyEither-->EitherString to allow Haskell98 instance
      
      Fri Jan  4 16:13:29 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * re-portabilize Pretty, and corresponding changes
      
      Fri Jan  4 17:19:55 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * Augment FastTypes to be much more complete
      
      Fri Jan  4 20:14:19 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * use FastFunctions, cleanup FastString slightly
      
      Fri Jan  4 21:00:22 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * Massive de-"#", mostly Int# --> FastInt (#1405)
      
      Fri Jan  4 21:02:49 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * miscellaneous unnecessary-extension-removal
      
      Sat Jan  5 19:30:13 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * add FastFunctions
      206b4dec
  30. 25 Dec, 2007 1 commit
    • chevalier@alum.wellesley.edu's avatar
      Extend API for compiling to and from Core · 98c68a1c
      chevalier@alum.wellesley.edu authored
      Added API support for compiling Haskell to simplified Core, and for
      compiling Core to machine code. The latter, especially, should be
      considered experimental and has only been given cursory testing. Also
      fixed warnings in DriverPipeline. Merry Christmas.
      98c68a1c
  31. 04 Dec, 2007 1 commit
  32. 06 Nov, 2007 1 commit
    • Simon Marlow's avatar
      GHC API: add checkAndLoadModule · 7379e82a
      Simon Marlow authored
      Does what the name suggests: it performs the function of both
      checkModule and load on that module, avoiding the need to process each
      module twice when checking a batch of modules.  This will make Haddock
      and ghctags much faster.
      
      Along with this is the beginnings of a refactoring of the HscMain
      interface.  HscMain now exports functions for separately running the
      parser, typechecher, and generating ModIface and ModDetails.
      Eventually the plan is to complete this interface and use it to
      replace the existing one.
      7379e82a
  33. 27 Oct, 2007 1 commit
    • chevalier@alum.wellesley.edu's avatar
      Make compileToCore return the module name and type environment along with bindings · 8102af4e
      chevalier@alum.wellesley.edu authored
        compileToCore returned just a list of CoreBind, which isn't enough,
      since to do anything with the resulting Core code, you probably also
      want the type declarations. I left compileToCore as it is, but added a
      function compileToCoreModule that returns a complete Core module (with
      module name, type environment, and bindings). I'm not sure that
      returning the type environment is the best way to represent the type
      declarations for the given module, but I don't want to reinvent the
      External Core wheel for this.
      8102af4e
  34. 10 Oct, 2007 1 commit
    • Dan Licata's avatar
      View patterns, record wildcards, and record puns · 6a05ec5e
      Dan Licata authored
      This patch implements three new features:
      * view patterns (syntax: expression -> pat in a pattern)
      * working versions of record wildcards and record puns
      See the manual for detailed descriptions.
      
      Other minor observable changes:
      * There is a check prohibiting local fixity declarations
        when the variable being fixed is not defined in the same let
      * The warn-unused-binds option now reports warnings for do and mdo stmts
      
      Implementation notes: 
      
      * The pattern renamer is now in its own module, RnPat, and the
      implementation is now in a CPS style so that the correct context is
      delivered to pattern expressions.
      
      * These features required a fairly major upheaval to the renamer.
      Whereas the old version used to collect up all the bindings from a let
      (or top-level, or recursive do statement, ...) and put them into scope
      before renaming anything, the new version does the collection as it
      renames.  This allows us to do the right thing with record wildcard
      patterns (which need to be expanded to see what names should be
      collected), and it allows us to implement the desired semantics for view
      patterns in lets.  This change had a bunch of domino effects brought on
      by fiddling with the top-level renaming.
      
      * Prior to this patch, there was a tricky bug in mkRecordSelId in HEAD,
      which did not maintain the invariant necessary for loadDecl.  See note
      [Tricky iface loop] for details.
      6a05ec5e