1. 03 Dec, 2001 2 commits
    • simonpj's avatar
      [project @ 2001-12-03 11:45:32 by simonpj] · 3178cb8b
      simonpj authored
      Dont fall over on data T deriving(Show)
      3178cb8b
    • simonpj's avatar
      [project @ 2001-12-03 11:36:26 by simonpj] · 525aeb93
      simonpj authored
      ------------------------------------
      	Fix a tiresome and longstanding bug
      	in typechecking of unlifted bindings
      	------------------------------------
      
      Consider
      
      	data T = MkT Int# Int#
      
      	f :: T -> Int#
      	f t = a +# b
      	    where
      	      MkT a b = if ... then t else t
      
      This should really be OK, but if the "..." includes
      some constraints, the constraint simplifier was trying to
      generate some d1=d2 bindings. This is Bad because the desugarer
      treats unlifted bindings very specially (they are strict).
      
      This commit fixes the problem, by ensuring we never get
      local dictionary binding for an unlifted group.
      
      This fixes the bug which has been making the Alpha port fall
      over with a pattern-match failure in DsExpr.  Nothing to do
      with Alpha; it's just that the word-size change gave rise
      to a little more commoning-up of literals in the type checker
      which in turn made the desugarer it fall over.
      525aeb93
  2. 02 Dec, 2001 1 commit
    • panne's avatar
      [project @ 2001-12-02 15:47:08 by panne] · d1255b8f
      panne authored
      Hmmm, we probably should install HsStd.h, too. PackageSrc.hs mentions
      it, and "make boot" in ghc/utils/hsc2hs fails without it. Perhaps this
      should be fixed differently, but I can't figure out how to do this
      correctly...
      d1255b8f
  3. 30 Nov, 2001 3 commits
  4. 29 Nov, 2001 3 commits
    • simonmar's avatar
      [project @ 2001-11-29 16:38:13 by simonmar] · b560e2a5
      simonmar authored
      Fix for heap profiling when selecting by lag/drag/void/use: I forgot
      to make the final LdvCensusKillAll() call just before outputing the
      census info.
      
      Having tested this stuff on the compiler itself, I now declare it to
      be working (famous last words!).
      b560e2a5
    • simonpj's avatar
      [project @ 2001-11-29 13:47:09 by simonpj] · 32a89583
      simonpj authored
      ------------------------------
      	Add linear implicit parameters
      	------------------------------
      
      Linear implicit parameters are an idea developed by Koen Claessen,
      Mark Shields, and Simon PJ, last week.  They address the long-standing
      problem that monads seem over-kill for certain sorts of problem, notably:
      
      	* distributing a supply of unique names
      	* distributing a suppply of random numbers
      	* distributing an oracle (as in QuickCheck)
      
      
      Linear implicit parameters are just like ordinary implicit parameters,
      except that they are "linear" -- that is, they cannot be copied, and
      must be explicitly "split" instead.  Linear implicit parameters are
      written '%x' instead of '?x'.  (The '/' in the '%' suggests the
      split!)
      
      For example:
      
          data NameSupply = ...
      
          splitNS :: NameSupply -> (NameSupply, NameSupply)
          newName :: NameSupply -> Name
      
          instance PrelSplit.Splittable NameSupply where
      	split = splitNS
      
      
          f :: (%ns :: NameSupply) => Env -> Expr -> Expr
          f env (Lam x e) = Lam x' (f env e)
      		    where
      		      x'   = newName %ns
      		      env' = extend env x x'
          ...more equations for f...
      
      Notice that the implicit parameter %ns is consumed
      	once by the call to newName
      	once by the recursive call to f
      
      So the translation done by the type checker makes
      the parameter explicit:
      
          f :: NameSupply -> Env -> Expr -> Expr
          f ns env (Lam x e) = Lam x' (f ns1 env e)
      		       where
      	 		 (ns1,ns2) = splitNS ns
      			 x' = newName ns2
      			 env = extend env x x'
      
      Notice the call to 'split' introduced by the type checker.
      How did it know to use 'splitNS'?  Because what it really did
      was to introduce a call to the overloaded function 'split',
      ndefined by
      
      	class Splittable a where
      	  split :: a -> (a,a)
      
      The instance for Splittable NameSupply tells GHC how to implement
      split for name supplies.  But we can simply write
      
      	g x = (x, %ns, %ns)
      
      and GHC will infer
      
      	g :: (Splittable a, %ns :: a) => b -> (b,a,a)
      
      The Splittable class is built into GHC.  It's defined in PrelSplit,
      and exported by GlaExts.
      
      Other points:
      
      * '?x' and '%x' are entirely distinct implicit parameters: you
        can use them together and they won't intefere with each other.
      
      * You can bind linear implicit parameters in 'with' clauses.
      
      * You cannot have implicit parameters (whether linear or not)
        in the context of a class or instance declaration.
      
      
      Warnings
      ~~~~~~~~
      The monomorphism restriction is even more important than usual.
      Consider the example above:
      
          f :: (%ns :: NameSupply) => Env -> Expr -> Expr
          f env (Lam x e) = Lam x' (f env e)
      		    where
      		      x'   = newName %ns
      		      env' = extend env x x'
      
      If we replaced the two occurrences of x' by (newName %ns), which is
      usually a harmless thing to do, we get:
      
          f :: (%ns :: NameSupply) => Env -> Expr -> Expr
          f env (Lam x e) = Lam (newName %ns) (f env e)
      		    where
      		      env' = extend env x (newName %ns)
      
      But now the name supply is consumed in *three* places
      (the two calls to newName,and the recursive call to f), so
      the result is utterly different.  Urk!  We don't even have
      the beta rule.
      
      Well, this is an experimental change.  With implicit
      parameters we have already lost beta reduction anyway, and
      (as John Launchbury puts it) we can't sensibly reason about
      Haskell programs without knowing their typing.
      
      Of course, none of this is throughly tested, either.
      32a89583
    • simonpj's avatar
      [project @ 2001-11-29 12:20:08 by simonpj] · 0fe14834
      simonpj authored
      Wibble in TcPat; fixes the stage2 build problem in AsmCodeGen
      0fe14834
  5. 28 Nov, 2001 11 commits
    • simonmar's avatar
      [project @ 2001-11-28 17:45:13 by simonmar] · 20977132
      simonmar authored
      oops, I broke standard -hb profiles.  Unbreak them again.
      20977132
    • simonmar's avatar
      [project @ 2001-11-28 15:43:23 by simonmar] · f1829925
      simonmar authored
      Make it work in a DEBUG world again (when DEBUG is on we have ancient
      support for doing a heap profile based on info-tables - it is still
      there, but I haven't tested it).
      f1829925
    • simonmar's avatar
      [project @ 2001-11-28 15:42:26 by simonmar] · a4e17de6
      simonmar authored
      Don't need the .prof file when LDV-profiling.
      a4e17de6
    • simonmar's avatar
      [project @ 2001-11-28 15:42:05 by simonmar] · 9e32d969
      simonmar authored
      Fix the test for calling LdvCensusForDead().
      9e32d969
    • simonmar's avatar
      [project @ 2001-11-28 15:01:02 by simonmar] · 6313b907
      simonmar authored
      As promised: allow selecting by lag, drag, void or use.  Currently
      this involves keeping around all the information about previous
      censuses, so memory use could get quite large.  If this turns out to
      be a problem, then we have a plan to throw away some of the info after
      each census.
      6313b907
    • simonmar's avatar
      [project @ 2001-11-28 14:55:34 by simonmar] · 3c22fb21
      simonmar authored
      The curly braces around heap profile selectors are now optional (and
      deprecated).
      
      Two reasons: having to quote the options is a real PITA and gets even
      worse when trying to use them from a Makefile, and this also brings us
      closer to nhc's option format.
      3c22fb21
    • simonmar's avatar
      [project @ 2001-11-28 14:47:54 by simonmar] · 4746806f
      simonmar authored
      Cross fingers and remove code that zeroes the nursery when doing LDV
      profiling.  This was required for two reasons:
      
        - the compiler might leave slop between objects when it is
          allocating.  However, it doesn't do this any more: we always
          move the heap pointer back at the end of a basic block if it
          turns out we didn't need all the heap,
      
        - After a heap check failure, we don't know what the previous
          value of Hp was, so we don't know where the end of the real
          data in the current nursery block is.
      
          This isn't the case any more, because as a side effect of the
          fixes to support big-block allocation we always shift Hp back
          by the required amount after a heap check failure, so now
          bd->free always points to the byte after the last allocated
          byte in a nursery block.
      4746806f
    • simonmar's avatar
      [project @ 2001-11-28 14:31:27 by simonmar] · 4321b113
      simonmar authored
      Revert previous commit:  I accidentally committed my local version of
      this file which has BLOCK_SIZE set to 2k rather than 4k (for testing).
      4321b113
    • simonmar's avatar
      [project @ 2001-11-28 14:30:32 by simonmar] · 117bf3f0
      simonmar authored
      Add a non-inline version of Bdescr() for use in gdb.
      117bf3f0
    • simonmar's avatar
      [project @ 2001-11-28 14:29:59 by simonmar] · 652b549f
      simonmar authored
      Don't close the stats file if it is stderr.
      652b549f
    • simonmar's avatar
      [project @ 2001-11-28 14:29:33 by simonmar] · 46eb785a
      simonmar authored
      oops!  There's a hand-written magic heap check in stg_update_PAP that
      I missed when I did the recent HpAlloc changes to fix the big block
      alloc problem.  Also remove a redundant comment about LDV profiling,
      and a redundant #ifdef.
      46eb785a
  6. 27 Nov, 2001 13 commits
  7. 26 Nov, 2001 7 commits
    • sof's avatar
      [project @ 2001-11-26 23:56:04 by sof] · 343b371a
      sof authored
      have happy-inplace rule depend on glafp-utils/
      343b371a
    • sof's avatar
      [project @ 2001-11-26 23:55:27 by sof] · b5cfaf64
      sof authored
      make it work on non-mingw platforms
      b5cfaf64
    • sof's avatar
      [project @ 2001-11-26 20:04:00 by sof] · 9746e23a
      sof authored
      Make the IO implementation work with WinSock once again.
      
      When creating sockets with WinSock, you don't get back
      a file descriptor, but a SOCKET (which just so happens
      to map to the same type as a 'normal' file descriptor).
      This SOCKET value cannot be used with the CRT ops
      read(), write(), close(), but you have to use the
      socket-specific operations (recv(), send(), and closesocket(),
      respectively) instead.
      
      To keep track of this distinction between file and
      socket file descriptors, the following changes were
      made:
      
      * a Handle__ has got a new field, haIsStream, which is True
        for sockets / streams.
        (this field is essentially unused in non-Win32 settings,
         but I decided not to conditionalise its presence).
      * PrelHandle.openFd now takes an extra (Maybe FDType) argument,
        which lets you force what type of FD we're converting into
        a Handle (this is crucial for WinSock SOCKETs, since we don't
        want to attempt fstat()ing them).
      
      Fixes breakage that was introduced with May 2001 (or earlier)
      rewrite of the IO layer. This commit build upon recent IO changes
      to HEAD, so merging it to STABLE will require importing those
      changes too (I'll let others be the judge whether this should
      be done or not).
      9746e23a
    • sof's avatar
      [project @ 2001-11-26 19:43:23 by sof] · 254849fc
      sof authored
      win32 only - provide closeFd, which closes a file descriptor, be it of
      file or socket ilk.
      254849fc
    • simonmar's avatar
      [project @ 2001-11-26 16:54:21 by simonmar] · dbef766c
      simonmar authored
      Profiling cleanup.
      
      This commit eliminates some duplication in the various heap profiling
      subsystems, and generally centralises much of the machinery.  The key
      concept is the separation of a heap *census* (which is now done in one
      place only instead of three) from the calculation of retainer sets.
      Previously the retainer profiling code also did a heap census on the
      fly, and lag-drag-void profiling had its own census machinery.
      
      Value-adds:
      
         - you can now restrict a heap profile to certain retainer sets,
           but still display by cost centre (or type, or closure or
           whatever).
      
         - I've added an option to restrict the maximum retainer set size
           (+RTS -R<size>, defaulting to 8).
      
         - I've cleaned up the heap profiling options at the request of
           Simon PJ.  See the help text for details.  The new scheme
           is backwards compatible with the old.
      
         - I've removed some odd bits of LDV or retainer profiling-specific
           code from various parts of the system.
      
         - the time taken doing heap censuses (and retainer set calculation)
           is now accurately reported by the RTS when you say +RTS -Sstderr.
      
      Still to come:
      
         - restricting a profile to a particular biography
           (lag/drag/void/use).  This requires keeping old heap censuses
           around, but the infrastructure is now in place to do this.
      dbef766c
    • sof's avatar
      [project @ 2001-11-26 16:37:33 by sof] · 5680ea4b
      sof authored
      fdType: clarify that this op will fail with non-file handles/descriptors
              under Win32.
      5680ea4b
    • simonmar's avatar
      [project @ 2001-11-26 13:06:49 by simonmar] · 18ea22a1
      simonmar authored
      Use an arena internally to allocate hash bucket cells instead of the
      current home-brewed combination of malloc/free and a free list.
      
      We still allocate hash table segments using malloc/free because these
      are large (4k by default) and might interact badly with the blockish
      nature of the arena allocator.
      18ea22a1