1. 19 Nov, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-11-19 14:59:53 by simonmar] · e72b2ad4
      simonmar authored
      fix repType after changes to the representation of type synonyms.
      This caused the stage2 compiler to crash, because various info tables
      misrepresented the pointerhood of constructor arguments.
      e72b2ad4
  2. 16 Nov, 2005 2 commits
    • simonpj's avatar
      [project @ 2005-11-16 17:45:38 by simonpj] · 491c85e7
      simonpj authored
      Better error reporting for newtypes with too many constructors,
      or too many fields.  Instead of yielding a parse error, we
      parse it like a data type declaration, and give a comprehensible
      error message later.
      
      A suggestion from Jan-Willem.
      491c85e7
    • simonpj's avatar
      [project @ 2005-11-16 12:55:58 by simonpj] · cdea9949
      simonpj authored
      Two significant changes to the representation of types
      
      1. Change the representation of type synonyms
      
          Up to now, type synonym applications have been held in
          *both* expanded *and* un-expanded form.  Unfortunately, this
          has exponential (!) behaviour when type synonyms are deeply
          nested.  E.g.
      	    type P a b = (a,b)
      	    f :: P a (P b (P c (P d e)))
          
          This showed up in a program of Joel Reymont, now immortalised
          as typecheck/should_compile/syn-perf.hs
      
          So now synonyms are held as ordinary TyConApps, and expanded
          only on demand.  
      
          SynNote has disappeared altogether, so the only remaining TyNote
          is a FTVNote.  I'm not sure if it's even useful.
      
      2. Eta-reduce newtypes
      
          See the Note [Newtype eta] in TyCon.lhs
          
          If we have 
      	    newtype T a b = MkT (S a b)
          
          then, in Core land, we would like S = T, even though the application
          of T is then not saturated. This commit eta-reduces T's RHS, and
          keeps that inside the TyCon (in nt_etad_rhs).  Result is that 
          coreEqType can be simpler, and has less need of expanding newtypes.
      cdea9949
  3. 15 Nov, 2005 1 commit
  4. 12 Nov, 2005 1 commit
    • simonpj's avatar
      [project @ 2005-11-12 21:41:12 by simonpj] · 87998beb
      simonpj authored
      Better TH -> HsSyn conversion
      
      	Merge to stable (attempt)
      
      This commit monad-ises the TH syntax -> HS syntax conversion.
      This means that error messages can be reported in a more civilised
      way.  It also ensures that the entire structure is converted eagerly.
      That means that any exceptions buried inside it are triggered 
      during conversion, and caught by the exception handler in TcSplice.
      Before, they could be triggered later, and looked like comiler
      crashes.
      87998beb
  5. 09 Nov, 2005 1 commit
  6. 08 Nov, 2005 2 commits
    • simonmar's avatar
      [project @ 2005-11-08 12:56:04 by simonmar] · 03341842
      simonmar authored
      gcc's -fstrict-aliasing is biting us when we use the stack to store
      different types of objects.  For example:
      
        *((StgDouble*)((W_)Sp-8)) = *((StgDouble*)((W_)Sp+8));
        Sp[1] = (W_)&s1Cx_info;
      
      gcc feels free to reorder these two lines, because they refer to
      differently typed objects, even though the assignment to Sp[1] clearly
      aliases the read from the same location.
      
      Trying to fix this by accessing locations using union types might be
      possible, but I took the sledgehammer approach of
      -fno-strict-aliasing.  This is justified to a certain extent because
      our generated C code is derived from a very weakly-typed internal
      language (C--).
      03341842
    • simonmar's avatar
      [project @ 2005-11-08 12:31:36 by simonmar] · 27249023
      simonmar authored
      unless I'm mistaken, only x86 needs -ffloat-store.  x86_64 certainly
      doesn't need it, because it uses SSE2 with the correct-sized floating
      point registers and doesn't store temporary results with more
      precision than results in memory.
      27249023
  7. 04 Nov, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-11-04 15:48:25 by simonmar] · be8b6cd5
      simonmar authored
      - Add support for the GHC_PACKAGE_PATH environment variable, which
        specifies a :-separated (;-separated on Windows) list of package
        database files.  If the list ends in : (; on Windows), then the
        normal user and global databases are added.
      
        GHC_PACKAGE_PATH is searched left-to-right for packages, like
        $PATH, but unlike -package-conf flags, which are searched
        right-to-left.  This isn't ideal, but it seemed the least worst to me
        (command line flags always override right-to-left (except -i),
        whereas the PATH environment variable overrides left-to-right, I chose
        to follow the environment variable convention).  I can always change
        it if there's an outcry.
      
      - Rationalise the interpretation of --user, --global, and -f on the
        ghc-pkg command line.  The story is now this: --user and --global
        say which package database to *act upon*, they do not change the
        shape of the database stack.  -f pushes a database on the stack, and
        also requests that the specified database be the one to act upon, for
        commands that modify the database.  If a database is already on the stack,
        then -f just selects it as the one to act upon.
      
        This means you can have a bunch of databases in GHC_PACKAGE_PATH, and
        use -f to select the one to modify.
      be8b6cd5
  8. 03 Nov, 2005 1 commit
  9. 02 Nov, 2005 5 commits
    • simonpj's avatar
      [project @ 2005-11-02 17:41:00 by simonpj] · d068f518
      simonpj authored
      Second correction to the TH fix of Oct 26, involving thFAKE
      
      Original message
        1) A bug in the renaming of [d| brackets |]. The problem was
        that when we renamed the bracket we messed up the name cache, because
        the module was still that of the parent module. Now we set a fake
        module before renaming it.
      
      This commit fixes the typecheker problem in a different way,
      in tcLookupGlobal.
      d068f518
    • simonpj's avatar
      [project @ 2005-11-02 17:39:57 by simonpj] · acc7346e
      simonpj authored
      Trace output only
      acc7346e
    • simonmar's avatar
      [project @ 2005-11-02 11:56:56 by simonmar] · 3348660b
      simonmar authored
      Fix warnings when assigning the result of a foreign call to BaseReg
      (as now happens in SMP mode with resumeThread()).
      3348660b
    • simonpj's avatar
      [project @ 2005-11-02 09:57:45 by simonpj] · f7e8044f
      simonpj authored
      Correct the TH fix of Oct 26, involving thFAKE
      		MERGE TO STABLE
      
      Original message
        1) A bug in the renaming of [d| brackets |]. The problem was
        that when we renamed the bracket we messed up the name cache, because
        the module was still that of the parent module. Now we set a fake
        module before renaming it.
      
      But we have to tell the *typechecker* too, not just the renamer.
      See comments with TcSplice.tc_bracket (DecBr case).
      
      Should fix TH failures in the STABLE branch
      f7e8044f
    • simonpj's avatar
      [project @ 2005-11-02 09:53:18 by simonpj] · ca49225c
      simonpj authored
      Export lists
      ca49225c
  10. 31 Oct, 2005 2 commits
  11. 30 Oct, 2005 1 commit
    • krasimir's avatar
      [project @ 2005-10-30 19:12:31 by krasimir] · 6e64c691
      krasimir authored
      Change the way in which the .exe suffix to the output file is added. The reason
      is that "-o main" will generate main.exe on Windows while the doesFileExists "main"
      in DriverPipeline.link will return False.
      6e64c691
  12. 29 Oct, 2005 2 commits
    • krasimir's avatar
      [project @ 2005-10-29 18:13:52 by krasimir] · 57d26da8
      krasimir authored
      The guessed output file should have ".exe" extension on Windows. ld tends to
      add .exe automatically if the output file doesn't have extension but if
      we don't add the extension explicitly then the doesFileExists check in
      DriverPipeline.link will fail.
      57d26da8
    • panne's avatar
      [project @ 2005-10-29 14:19:59 by panne] · 26f300ce
      panne authored
      Fixed the last commit, which broke the nightly builds. I'm not sure if
      this is really a fix or a workaround only, though...
      26f300ce
  13. 28 Oct, 2005 3 commits
    • simonmar's avatar
      [project @ 2005-10-28 15:22:39 by simonmar] · f2e730f3
      simonmar authored
      Add -stubdir option to control location of generated stub files.  Also
      do some clean up while I'm here - remove hscStubCOut/hscStubHOut from
      DynFlags, and add
      
        mkStubPaths :: DynFlags -> Module -> ModLocation -> (FilePath,FilePath)
      
      to Finder.  (this seemed better than caching the stub paths in every
      ModLocation, because they are rarely needed and only present in home
      modules, and are easily calculated from other available information).
      
      -stubdir behaves in exactly the same way as -odir and -hidir.
      f2e730f3
    • simonmar's avatar
      [project @ 2005-10-28 11:35:35 by simonmar] · 55495951
      simonmar authored
      Change the default executable name to match the basename of the source
      file containing the Main module (or the module specified by -main-is),
      if there is one.  On Windows, the .exe extension is added.
      
      As requested on the ghc-users list, and as implemented by Tomasz
      Zielonka <tomasz.zielonka at gmail.com>, with modifications by me.
      
      I changed the type of the mainModIs field of DynFlags from Maybe
      String to Module, which removed some duplicate code.
      55495951
    • simonmar's avatar
      [project @ 2005-10-28 11:29:19 by simonmar] · d8afca91
      simonmar authored
      Fix double "Linking ..." message, and mention the name of the
      executable in the message.
      d8afca91
  14. 27 Oct, 2005 6 commits
    • simonpj's avatar
      [project @ 2005-10-27 15:21:05 by simonpj] · f9f5235f
      simonpj authored
      Improve warning a little (suggested by Benjamin Pierce)
      f9f5235f
    • simonpj's avatar
      [project @ 2005-10-27 14:35:20 by simonpj] · 958924a2
      simonpj authored
      Add a new pragma: SPECIALISE INLINE
      
      This amounts to adding an INLINE pragma to the specialised version
      of the function.  You can add phase stuff too (SPECIALISE INLINE [2]),
      and NOINLINE instead of INLINE.
      
      The reason for doing this is to support inlining of type-directed
      recursive functions.  The main example is this:
      
        -- non-uniform array type
        data Arr e where
          ArrInt  :: !Int -> ByteArray#       -> Arr Int
          ArrPair :: !Int -> Arr e1 -> Arr e2 -> Arr (e1, e2)
      
        (!:) :: Arr e -> Int -> e
        {-# SPECIALISE INLINE (!:) :: Arr Int -> Int -> Int #-}
        {-# SPECIALISE INLINE (!:) :: Arr (a, b) -> Int -> (a, b) #-}
        ArrInt  _ ba    !: (I# i) = I# (indexIntArray# ba i)
        ArrPair _ a1 a2 !: i      = (a1 !: i, a2 !: i)
      
      If we use (!:) at a particular array type, we want to inline (:!),
      which is recursive, until all the type specialisation is done.
      
      
      On the way I did a bit of renaming and tidying of the way that
      pragmas are carried, so quite a lot of files are touched in a
      fairly trivial way.
      958924a2
    • simonpj's avatar
      [project @ 2005-10-27 14:34:32 by simonpj] · 47d253ba
      simonpj authored
      Filter out inaccessible GADT alternatives
      47d253ba
    • simonpj's avatar
      [project @ 2005-10-27 13:51:27 by simonpj] · ca1b9eb2
      simonpj authored
      Allow GADTs in record update, provided all the relevant datacons are
      vanilla.  Turns out that ObjectIO.StdMenuElement uses this facility!
      
      This a slight enhancement to the new stuff allowing record
      fields in GADTs.
      ca1b9eb2
    • sof's avatar
      [project @ 2005-10-27 01:39:40 by sof] · 2909e6fb
      sof authored
      [mingw/msys only]
      Undo long-standing workaround for buggy GNU ld's on mingw/msys; i.e.,
      the linker wasn't correctly generating relocatable object files when
      the number of relocs exceeded 2^16. Worked around the issue by
      hackily splitting up the GHCi object file for the larger packages
      ('base', 'ObjectIO' and 'win32') into a handful of object files,
      each with a manageable number of relocs. Tiresome and error-prone
      (but the hack has served us well!)
      
      This commit imposes a restriction on the 'ld' you use to compile
      up GHC with; it now has to be ld-2.15.x or later (something GHC
      binary dists have shipped with since 6.2.2)
      2909e6fb
    • sof's avatar
      [project @ 2005-10-27 00:21:24 by sof] · 8f94d42a
      sof authored
      emitForeignCall: avoid CC warnings by hinting that resume/suspendThread id arg is a ptr
      8f94d42a
  15. 26 Oct, 2005 3 commits
    • simonpj's avatar
      [project @ 2005-10-26 12:35:12 by simonpj] · 07806d2b
      simonpj authored
      Simplify Provenance (the LocalDef constructor) a little
      07806d2b
    • simonpj's avatar
      [project @ 2005-10-26 12:05:03 by simonpj] · 015aa972
      simonpj authored
      MERGE TO STABLE
      
      Fix two small Template Haskell bugs.
      
      (1) A bug in the renaming of [d| brackets |].  The problem was
      that when we renamed the bracket we messed up the name cache, because
      the module was still that of the parent module.  Now we set a fake
      module before renaming it.
      
      TH_spliceDecl4 is the test.
      
      (2) An expression splice can in principle mention *any* variable,
      so the renamer really has to assume that it does when doing depdendency
      analysis.  For example
      	f = ...
      	h = ...$(thing "f")...
      The renamer had better not put 'h' before 'f', else the type checker
      won't find a defn for 'f' in the type envt.
      
      TH_spliceE5 is the test
      015aa972
    • simonpj's avatar
      [project @ 2005-10-26 10:23:47 by simonpj] · 474656aa
      simonpj authored
      Cosmetics
      474656aa
  16. 25 Oct, 2005 3 commits
    • simonmar's avatar
      [project @ 2005-10-25 15:04:58 by simonmar] · 7662a4ce
      simonmar authored
      add missing boot files
      7662a4ce
    • simonmar's avatar
      [project @ 2005-10-25 12:48:35 by simonmar] · 78b72ed1
      simonmar authored
      Two changes from Krasimir Angelov, which were required for Visual
      Haskell:
      
        - messaging cleanup throughout the compiler.  DynFlags has a new
          field:
      
          log_action :: Severity -> SrcSpan -> PprStyle -> Message -> IO ()
      
          this action is invoked for every message generated by the
          compiler.  This means a client of the GHC API can direct messages to
          any destination, or collect them up in an IORef for later
          perusal.
      
          This replaces previous hacks to redirect messages in the GHC API
          (hence some changes to function types in GHC.hs).
      
        - The JustTypecheck mode of GHC now does what it says.  It doesn't
          run any of the compiler passes beyond the typechecker for each module,
          but does generate the ModIface in order that further modules can be
          typechecked.
      
      And one change from me:
      
        - implement the LANGUAGE pragma, finally
      78b72ed1
    • simonmar's avatar
      [project @ 2005-10-25 10:48:44 by simonmar] · 2909e581
      simonmar authored
      companion to Lexer.x rev. 1.29; columns now always count tabs as 1 in SrcLoc.
      2909e581
  17. 21 Oct, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-10-21 14:02:17 by simonmar] · 03a9ff01
      simonmar authored
      Big re-hash of the threaded/SMP runtime
      
      This is a significant reworking of the threaded and SMP parts of
      the runtime.  There are two overall goals here:
      
        - To push down the scheduler lock, reducing contention and allowing
          more parts of the system to run without locks.  In particular,
          the scheduler does not require a lock any more in the common case.
      
        - To improve affinity, so that running Haskell threads stick to the
          same OS threads as much as possible.
      
      At this point we have the basic structure working, but there are some
      pieces missing.  I believe it's reasonably stable - the important
      parts of the testsuite pass in all the (normal,threaded,SMP) ways.
      
      In more detail:
      
        - Each capability now has a run queue, instead of one global run
          queue.  The Capability and Task APIs have been completely
          rewritten; see Capability.h and Task.h for the details.
      
        - Each capability has its own pool of worker Tasks.  Hence, Haskell
          threads on a Capability's run queue will run on the same worker
          Task(s).  As long as the OS is doing something reasonable, this
          should mean they usually stick to the same CPU.  Another way to
          look at this is that we're assuming each Capability is associated
          with a fixed CPU.
      
        - What used to be StgMainThread is now part of the Task structure.
          Every OS thread in the runtime has an associated Task, and it
          can ask for its current Task at any time with myTask().
      
        - removed RTS_SUPPORTS_THREADS symbol, use THREADED_RTS instead
          (it is now defined for SMP too).
      
        - The RtsAPI has had to change; we must explicitly pass a Capability
          around now.  The previous interface assumed some global state.
          SchedAPI has also changed a lot.
      
        - The OSThreads API now supports thread-local storage, used to
          implement myTask(), although it could be done more efficiently
          using gcc's __thread extension when available.
      
        - I've moved some POSIX-specific stuff into the posix subdirectory,
          moving in the direction of separating out platform-specific
          implementations.
      
        - lots of lock-debugging and assertions in the runtime.  In particular,
          when DEBUG is on, we catch multiple ACQUIRE_LOCK()s, and there is
          also an ASSERT_LOCK_HELD() call.
      
      What's missing so far:
      
        - I have almost certainly broken the Win32 build, will fix soon.
      
        - any kind of thread migration or load balancing.  This is high up
          the agenda, though.
      
        - various performance tweaks to do
      
        - throwTo and forkProcess still do not work in SMP mode
      03a9ff01
  18. 20 Oct, 2005 2 commits
    • simonmar's avatar
      [project @ 2005-10-20 14:00:36 by simonmar] · 63e8af08
      simonmar authored
      Column numbers in SrcLocs are now counted as the number of characters,
      rather than columns.  i.e. a tab always counts as 1.  This was
      necessary for communication with Visual Studio interfaces which expect
      character indices, but also it seems the majority of other compilers
      also do things this way.
      
      From: Krasimir Angelov <kr.angelov@gmail.com>
      63e8af08
    • sof's avatar
      [project @ 2005-10-20 00:52:38 by sof] · c86b512d
      sof authored
      [mingw]delay flushing console buffer until last possible moment. Merge to STABLE
      c86b512d
  19. 17 Oct, 2005 2 commits
    • simonpj's avatar
      [project @ 2005-10-17 11:11:15 by simonpj] · 9137abfe
      simonpj authored
      Buglets in GADT record-syntax stuff, which killed the weekend builds
      9137abfe
    • simonpj's avatar
      [project @ 2005-10-17 11:10:36 by simonpj] · b16992d6
      simonpj authored
      Small simplifier bug in case optimisation
      	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      The simplifier eliminates redundant case branches, and panics if there
      are no case alternatives.  But due to a slightly delayed instantiation
      of a type constructor variable 'p' by a type constructor 'P', it turned
      out that an inner case had no alternatives at all, becuase an outer case
      had not pruned a branch as quickly as it should have.
      
      This commit fixes both problems:
      
      a) SimplUtils.mkCase1 now returns a call to 'error' (instead of panicing)
         when it gets an empty list of alternatives.   Somewhat analogous to
         the inaccessible GADT case in Simplify.simplifyAlt
      
      b) In SimplUtils.prepareDefault, use the up-to-date scrutinee, rather than
         the less up-to-date case_bndr, to get the case type constructor.  That
         leads to slightly earlier pruning of inaccessible branches.
      
      Fixes a bug reported by Ian Lynagh.
      
      Test is simplCore/should_compile/simpl013
      b16992d6