1. 27 Nov, 2001 2 commits
    • sof's avatar
      [project @ 2001-11-27 01:51:23 by sof] · e30e0fb8
      sof authored
      Rearranged how the virtual timer 'subsystem' is brought up and down:
      
      * "int startVirtTimer(nat ms)" now starts the vtimer/ticker.
      * "int stopVirtTimer()" shuts down the ticker.
      
      i.e., removed install_vtalrm_handler() and initialize_virtual_timer().
      e30e0fb8
    • sof's avatar
      [project @ 2001-11-27 00:18:59 by sof] · 5985b613
      sof authored
      track 5.03's change to PrelHandle.fillReadBuffer
      5985b613
  2. 26 Nov, 2001 15 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
    • simonpj's avatar
      [project @ 2001-11-26 12:58:17 by simonpj] · d6181fe1
      simonpj authored
      In the Win32 build, don't call initProfTimer unless PROFILING
      is on.  This mirrors the Unix deal.   Indeed initProfTimer
      isn't defined if PROFILING is on.
      
      I don't know how this works for anyone else on Win32!
      Sigbjorn: have I done this right, or am I misunderstanding?
      d6181fe1
    • simonpj's avatar
      [project @ 2001-11-26 10:33:40 by simonpj] · 5a1ac8dc
      simonpj authored
      Complete previous tcAddImportedIdInfo commit
      5a1ac8dc
    • simonpj's avatar
      [project @ 2001-11-26 10:30:15 by simonpj] · aa2901f9
      simonpj authored
      Improve error reporting
      aa2901f9
    • simonpj's avatar
      [project @ 2001-11-26 10:27:14 by simonpj] · eb06b89f
      simonpj authored
      Comments only
      eb06b89f
    • simonpj's avatar
      [project @ 2001-11-26 10:26:59 by simonpj] · 1fdd97b6
      simonpj authored
      --------------------------------------
      	Finally get rid of tcAddImportedIdInfo
      	--------------------------------------
      
      TcEnv.tcAddImportedIdInfo is a notorious source of space leaks.
      Simon M got rid of the need for it on default methods.
      This commit gets rid of the need for it for dictionary function Ids,
      and finally nukes the beast altogether. Hurrah!
      
      The change really involves putting tcInterfaceSigs *before*
      tcInstDecls1, so that any imported DFunIds are in the typechecker's
      environment before we get to tcInstDecls.
      1fdd97b6
    • simonpj's avatar
      [project @ 2001-11-26 09:22:05 by simonpj] · 0760818e
      simonpj authored
      Add missing files for Rank-N commit
      0760818e
    • simonpj's avatar
      [project @ 2001-11-26 09:20:25 by simonpj] · 5e3f005d
      simonpj authored
      ----------------------
      	Implement Rank-N types
      	----------------------
      
      This commit implements the full glory of Rank-N types, using
      the Odersky/Laufer approach described in their paper
      	"Putting type annotations to work"
      
      In fact, I've had to adapt their approach to deal with the
      full glory of Haskell (including pattern matching, and the
      scoped-type-variable extension).  However, the result is:
      
      * There is no restriction to rank-2 types.  You can nest forall's
        as deep as you like in a type.  For example, you can write a type
        like
      	p :: ((forall a. Eq a => a->a) -> Int) -> Int
        This is a rank-3 type, illegal in GHC 5.02
      
      * When matching types, GHC uses the cunning Odersky/Laufer coercion
        rules.  For example, suppose we have
      	q :: (forall c. Ord c => c->c) -> Int
        Then, is this well typed?
      	x :: Int
      	x = p q
        Yes, it is, but GHC has to generate the right coercion.  Here's
        what it looks like with all the big lambdas and dictionaries put in:
      
      	x = p (\ f :: (forall a. Eq a => a->a) ->
      		 q (/\c \d::Ord c -> f c (eqFromOrd d)))
      
        where eqFromOrd selects the Eq superclass dictionary from the Ord
        dicationary:		eqFromOrd :: Ord a -> Eq a
      
      
      * You can use polymorphic types in pattern type signatures.  For
        example:
      
      	f (g :: forall a. a->a) = (g 'c', g True)
      
        (Previously, pattern type signatures had to be monotypes.)
      
      * The basic rule for using rank-N types is that you must specify
        a type signature for every binder that you want to have a type
        scheme (as opposed to a plain monotype) as its type.
      
        However, you don't need to give the type signature on the
        binder (as I did above in the defn for f).  You can give it
        in a separate type signature, thus:
      
      	f :: (forall a. a->a) -> (Char,Bool)
      	f g = (g 'c', g True)
      
        GHC will push the external type signature inwards, and use
        that information to decorate the binders as it comes across them.
        I don't have a *precise* specification of this process, but I
        think it is obvious enough in practice.
      
      * In a type synonym you can use rank-N types too.  For example,
        you can write
      
      	type IdFun = forall a. a->a
      
      	f :: IdFun -> (Char,Bool)
      	f g = (g 'c', g True)
      
        As always, type synonyms must always occur saturated; GHC
        expands them before it does anything else.  (Still, GHC goes
        to some trouble to keep them unexpanded in error message.)
      
      
      The main plan is as before.  The main typechecker for expressions,
      tcExpr, takes an "expected type" as its argument.  This greatly
      improves error messages.  The new feature is that when this
      "expected type" (going down) meets an "actual type" (coming up)
      we use the new subsumption function
      	TcUnify.tcSub
      which checks that the actual type can be coerced into the
      expected type (and produces a coercion function to demonstrate).
      
      The main new chunk of code is TcUnify.tcSub.  The unifier itself
      is unchanged, but it has moved from TcMType into TcUnify.  Also
      checkSigTyVars has moved from TcMonoType into TcUnify.
      Result: the new module, TcUnify, contains all stuff relevant
      to subsumption and unification.
      
      Unfortunately, there is now an inevitable loop between TcUnify
      and TcSimplify, but that's just too bad (a simple TcUnify.hi-boot
      file).
      
      
      All of this doesn't come entirely for free.  Here's the typechecker
      line count (INCLUDING comments)
      	Before	16,551
      	After	17,116
      5e3f005d
    • chak's avatar
      [project @ 2001-11-26 08:31:05 by chak] · f5a6b456
      chak authored
      Added a new section that describes how GHC defines its hardwired knowledge
      about primitives and special prelude definitions.
      f5a6b456
  3. 25 Nov, 2001 3 commits
    • sof's avatar
      [project @ 2001-11-25 16:59:11 by sof] · 2b8262a3
      sof authored
      Tidyup - only declare&use half-a-dozen prof-only global variables
      when PROFILING.
      2b8262a3
    • sof's avatar
      [project @ 2001-11-25 16:57:38 by sof] · a412def3
      sof authored
      Retainer/LDV changes.
      
      The recent prof-related commit forgot to include RtsFlags.h, methinks.
      But, modulo trivia, I'm reasonably sure that this commit mirrors
      whatever mods that unchecked-in file contains.
      a412def3
    • sof's avatar
      [project @ 2001-11-25 03:56:39 by sof] · 502a4dc8
      sof authored
      extend the scope of the doNothing() macro; can now be used in Stg headers
      502a4dc8
  4. 23 Nov, 2001 12 commits
    • simonpj's avatar
      [project @ 2001-11-23 16:20:08 by simonpj] · 61120c8b
      simonpj authored
      Put spaces round %, in preparation for splittable name supplies
      61120c8b
    • simonmar's avatar
      [project @ 2001-11-23 15:43:39 by simonmar] · f8bf5817
      simonmar authored
      unbreak tcModule.
      f8bf5817
    • simonmar's avatar
      [project @ 2001-11-23 12:06:49 by simonmar] · dd823536
      simonmar authored
      Use (DefMeth Name) rather than (DefMeth Id) in ClassOpItem.  This not
      only eliminates a space leak, because Names generally hold on to much
      less stuff than Ids, but also turns out to be a minor cleanup.
      dd823536
    • simonmar's avatar
      [project @ 2001-11-23 12:03:59 by simonmar] · f4faa942
      simonmar authored
      Replace a lazy pattern match in tcGetInstLoc with a strict one (fixes
      a space leak).
      f4faa942
    • simonmar's avatar
      [project @ 2001-11-23 12:01:34 by simonmar] · c36b02d9
      simonmar authored
      Adorn various constructor fields with strictness annotations - this
      fixes at least one space leak, in the mi_usages field of a ModIface.
      c36b02d9
    • simonmar's avatar
      [project @ 2001-11-23 11:59:21 by simonmar] · 3642d212
      simonmar authored
      Collect up _scc_ expressions on the right hand side of a closure
      definition and attach them directly to the closure using PushCC-type
      cost centres, so that the allocation of the closure gets attributed to
      the right place.
      3642d212
    • simonmar's avatar
      [project @ 2001-11-23 11:57:59 by simonmar] · 79abe0ac
      simonmar authored
      Fix a long-standing bug in the cost attribution of cost-center stacks.
      The problem case is this:
      
      	let z = _scc_ "z" f x
      	in ... z ...
      
      previously we were attributing the cost of allocating the closure 'z'
      to the enclosing cost center stack (CCCS), when it should really be
      attributed to "z":CCCS.  The effects are particularly visible with
      retainer profiling, because the closure retaining 'f' and 'x' would
      show up with the wrong CCS attached.
      
      To fix this, we need a new form of CCS representation internally:
      'PushCC CostCentre CostCentreStack' which subsumes (and therefore
      replaces) SingletonCCS.  SingletonCCS is now represented by 'PushCC cc
      NoCCS'.
      
      The CCS argument to SET_HDR may now be an arbitrary expression, such
      as PushCostCentre(CCCS,foo_cc), as may be the argument to CCS_ALLOC().
      So we combine SET_HDR and CCS_ALLOC into a single macro, SET_HDR_, to
      avoid repeated calls to PushCostCentre().
      79abe0ac
    • simonmar's avatar
      [project @ 2001-11-23 11:47:37 by simonmar] · 7edf3bea
      simonmar authored
      Call LDV_ENTER() on entry to a constructor in profiling mode.
      7edf3bea
    • simonmar's avatar
      [project @ 2001-11-23 11:47:12 by simonmar] · 97349545
      simonmar authored
      Call LDV_ENTER() on entry to a thunk or function in profiling mode.
      97349545
    • simonmar's avatar
      [project @ 2001-11-23 11:46:31 by simonmar] · 0054140b
      simonmar authored
      Add
      	ldvEnter :: Code
      
      for LDV profiling: it records that the closure pointed to by R1 has
      just been entered.
      0054140b
    • simonmar's avatar
      [project @ 2001-11-23 11:42:11 by simonmar] · 9ef74223
      simonmar authored
      We don't need to consider Hp as a volatile register across C calls; it
      is already saved by the CALLER_SAVES_SYSTEM macro.
      9ef74223
    • simonmar's avatar
      [project @ 2001-11-23 10:27:58 by simonmar] · 986ac01d
      simonmar authored
      Fix compilation problems with Stats.c in the !DEBUG case.
      986ac01d
  5. 22 Nov, 2001 5 commits
    • simonmar's avatar
      [project @ 2001-11-22 16:33:06 by simonmar] · 9469779a
      simonmar authored
      Omit GC and SYSTEM from the cost centre summary at the top of the profile.
      9469779a
    • simonmar's avatar
      [project @ 2001-11-22 15:15:27 by simonmar] · 1041f9ab
      simonmar authored
      Add rts_getThreadId to the Linker's built in symbol table
      1041f9ab
    • simonmar's avatar
      [project @ 2001-11-22 14:25:11 by simonmar] · db61851c
      simonmar authored
      Retainer Profiling / Lag-drag-void profiling.
      
      This is mostly work by Sungwoo Park, who spent a summer internship at
      MSR Cambridge this year implementing these two types of heap profiling
      in GHC.
      
      Relative to Sungwoo's original work, I've made some improvements to
      the code:
      
         - it's now possible to apply constraints to retainer and LDV profiles
           in the same way as we do for other types of heap profile (eg.
           +RTS -hc{foo,bar} -hR -RTS gives you a retainer profiling considering
           only closures with cost centres 'foo' and 'bar').
      
         - the heap-profile timer implementation is cleaned up.
      
         - heap profiling no longer has to be run in a two-space heap.
      
         - general cleanup of the code and application of the SDM C coding
           style guidelines.
      
      Profiling will be a little slower and require more space than before,
      mainly because closures have an extra header word to support either
      retainer profiling or LDV profiling (you can't do both at the same
      time).
      
      We've used the new profiling tools on GHC itself, with moderate
      success.  Fixes for some space leaks in GHC to follow...
      db61851c
    • simonpj's avatar
      [project @ 2001-11-22 12:22:42 by simonpj] · a88cde39
      simonpj authored
      Inlining pragma buglet
      a88cde39
    • simonmar's avatar
      [project @ 2001-11-22 12:06:55 by simonmar] · 8f877d35
      simonmar authored
      Update this document.  Some of the implementation problems can be
      solved in a cleaner way, and the document was confused about the
      problems caused by slop in the heap (it's only a problem when
      traversing the dead heap, not the live heap).
      8f877d35
  6. 21 Nov, 2001 3 commits