1. 26 Nov, 2001 7 commits
    • simonpj's avatar
      [project @ 2001-11-26 10:33:40 by simonpj] · 5a1ac8dc
      simonpj authored
      Complete previous tcAddImportedIdInfo commit
    • simonpj's avatar
      [project @ 2001-11-26 10:30:15 by simonpj] · aa2901f9
      simonpj authored
      Improve error reporting
    • simonpj's avatar
      [project @ 2001-11-26 10:27:14 by simonpj] · eb06b89f
      simonpj authored
      Comments only
    • 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.
    • simonpj's avatar
      [project @ 2001-11-26 09:22:05 by simonpj] · 0760818e
      simonpj authored
      Add missing files for Rank-N commit
    • 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
      	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
      	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
      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
      All of this doesn't come entirely for free.  Here's the typechecker
      line count (INCLUDING comments)
      	Before	16,551
      	After	17,116
    • 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.
  2. 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.
    • 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.
    • 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
  3. 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
    • simonmar's avatar
      [project @ 2001-11-23 15:43:39 by simonmar] · f8bf5817
      simonmar authored
      unbreak tcModule.
    • 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.
    • 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).
    • 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.
    • 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.
    • 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
      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().
    • 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.
    • 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.
    • simonmar's avatar
      [project @ 2001-11-23 11:46:31 by simonmar] · 0054140b
      simonmar authored
      	ldvEnter :: Code
      for LDV profiling: it records that the closure pointed to by R1 has
      just been entered.
    • 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.
    • 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.
  4. 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.
    • 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
    • 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
      We've used the new profiling tools on GHC itself, with moderate
      success.  Fixes for some space leaks in GHC to follow...
    • simonpj's avatar
      [project @ 2001-11-22 12:22:42 by simonpj] · a88cde39
      simonpj authored
      Inlining pragma buglet
    • 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).
  5. 21 Nov, 2001 5 commits
    • sof's avatar
      [project @ 2001-11-21 20:55:10 by sof] · b88636e4
      sof authored
      initialize_virtual_timer: Robustified win32 version; don't
      assume that the minimal resolution is one millisec, consult
      the underlying impl via timeGetDevCaps().
    • sof's avatar
      [project @ 2001-11-21 20:27:18 by sof] · b79fdec2
      sof authored
      StablePtr indexes/counts are no longer weighted (i.e., sync wrt Stable.{c,h} changes)
    • sof's avatar
      [project @ 2001-11-21 16:56:19 by sof] · 22584fda
      sof authored
      #ifdef protect generated config.h file.
    • simonmar's avatar
      [project @ 2001-11-21 10:09:15 by simonmar] · 560bf0f6
      simonmar authored
      Turn the weighted reference count in a StablePtr into a simple counter
      in the stable ptr table.  We never made use of the weighted count, and
      it caused problems when making many StablePtrs to the same object.
      In the future we could remove the reference counting altogether and
      just make a new StablePtr each time, rather than attempting to use an
      existing one.  This would save on the hash table lookup at creation
    • sof's avatar
      [project @ 2001-11-21 02:29:00 by sof] · 1222b052
      sof authored
      Have prototypes and implementation of prel_PrelHandle_{write,read}() match
      up with the stated Haskell FFI type in PrelHandle.hs, i.e., the size
      parameter is a CInt, not an Int.
  6. 20 Nov, 2001 4 commits
    • sof's avatar
      [project @ 2001-11-20 21:39:12 by sof] · 1d5ba9bb
      sof authored
      getTimes (win32): Win9x OSes don't provide per-process timing data, so
      GetProcessTimes() doesn't do anything interesting. So, resort to using
      system-time instead to measure user/process time iff running under Win9x.
      (the precision is not as good, deltas were ~6 millisecs when testing
      on a Win98 box, but it's better than nothing).
      This change should make profiling on Win9x boxes finally work.
    • sof's avatar
      [project @ 2001-11-20 16:43:18 by sof] · 17035366
      sof authored
      Nuke #include of MachDeps.h - nothing in there that cannot be
      (better) gotten from the in-tree config.h
      This is the only (last?) use of MachDeps.h, so if anyone won't argue
      for its continued existence, I'll nuke it sometime soon.
    • simonmar's avatar
      [project @ 2001-11-20 16:17:23 by simonmar] · 62b639a5
      simonmar authored
      Print to stdout instead of stderr.  I'm pretty ambivalent about this,
      but Sungwoo Park made the changes as part of his retainer profiling
      work so he must have had a good reason for it at the time...
    • simonpj's avatar
      [project @ 2001-11-20 14:12:48 by simonpj] · 1d8621c1
      simonpj authored
      Add constant-folding rules for Float# and Double#
  7. 19 Nov, 2001 4 commits