1. 21 Oct, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-10-21 11:38:53 by simonmar] · 2be44cb2
      simonmar authored
      Bite the bullet and generalise the central memory allocation scheme.
      Previously we tried to allocate memory starting from a fixed address,
      which was set for each architecture (0x5000000 was a common one), and
      to decide whether a particular address was in the heap or not we would
      do a simple comparison against this address.
      
      This doesn't work too well, because:
      
       - if we dynamically-load some objects above the boundary, the
         heap-allocated test becomes invalid
      
       - on windows we have less control, and the heap might be
         split into multiple sections
      
       - it turns out that on some Linux kernels we don't get memory where
         we asked for it.  This might be a bug in those kernels, but it
         exposes the fragility of our allocation scheme.
      
      The solution is to bite the bullet and maintain a table mapping
      addresses to a value indicating whether that address is in the heap or
      not.  Since we normally allocate heap in chunks of 1Mb, the table is
      quite small: 4k on a 32-bit machine, using one byte for each 1Mb
      block.  Testing an address for heap residency now involves a memory
      access, but the table is normally cache-resident.  I didn't manage to
      measure any slowdown after making the change.
      
      On a 64-bit machine, we'll need to use a 2-level table; I haven't
      implemented that yet.
      
      Now we can generalise the procedure used to grab memory from the OS.
      In the general case, we allocate one megablock more than we need to,
      and trim off the slop around the allocation to leave an aligned chunk.
      The next time around, however, we try to allocate memory right after
      the last chunk allocated, on the grounds that it is aligned and
      probably free: if this doesn't work, we have to back off to the
      general mechanism (it seems to work most of the time).
      
      This cleans up the Windows story too: is_heap_alloced() has gone, and
      we should be able to handle more than 256M of memory (or whatever the
      arbitrary limit was before).
      
      MERGE TO STABLE (after lots of testing)
      2be44cb2
  2. 18 Oct, 2002 1 commit
  3. 15 Oct, 2002 1 commit
  4. 12 Oct, 2002 1 commit
    • wolfgang's avatar
      [project @ 2002-10-12 23:12:08 by wolfgang] · 31442604
      wolfgang authored
      Make the Mac OS X build use the HaskellSupport.framework (a MacOS-style "framework" that includes the required libraries libgmp and dlcompat) if it is present. The HaskellSupport.framework is not yet in CVS, but is available from me.
      31442604
  5. 05 Oct, 2002 2 commits
  6. 02 Oct, 2002 1 commit
  7. 01 Oct, 2002 1 commit
  8. 25 Sep, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-09-25 14:46:31 by simonmar] · 28e69a6b
      simonmar authored
      Fix a scheduling/GC bug, spotted by Wolfgang Thaller.  If a main
      thread completes, and a GC runs before the return (from rts_evalIO())
      happens, then the thread might be GC'd before we get a chance to
      extract its return value, leading to barf("main thread has been GC'd")
      from the garbage collector.
      
      The fix is to treat all main threads which have completed as roots:
      this is logically the right thing to do, because these threads must be
      retained by virtue of holding the return value, and this is a property of
      main threads only.
      28e69a6b
  9. 18 Sep, 2002 1 commit
  10. 17 Sep, 2002 5 commits
  11. 13 Sep, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-09-13 15:02:25 by simonpj] · 9af77fa4
      simonpj authored
      --------------------------------------
      	Make Template Haskell into the HEAD
      	--------------------------------------
      
      This massive commit transfers to the HEAD all the stuff that
      Simon and Tim have been doing on Template Haskell.  The
      meta-haskell-branch is no more!
      
      WARNING: make sure that you
      
        * Update your links if you are using link trees.
          Some modules have been added, some have gone away.
      
        * Do 'make clean' in all library trees.
          The interface file format has changed, and you can
          get strange panics (sadly) if GHC tries to read old interface files:
          e.g.  ghc-5.05: panic! (the `impossible' happened, GHC version 5.05):
      	  Binary.get(TyClDecl): ForeignType
      
        * You need to recompile the rts too; Linker.c has changed
      
      
      However the libraries are almost unaltered; just a tiny change in
      Base, and to the exports in Prelude.
      
      
      NOTE: so far as TH itself is concerned, expression splices work
      fine, but declaration splices are not complete.
      
      
      		---------------
      		The main change
      		---------------
      
      The main structural change: renaming and typechecking have to be
      interleaved, because we can't rename stuff after a declaration splice
      until after we've typechecked the stuff before (and the splice
      itself).
      
      * Combine the renamer and typecheker monads into one
      	(TcRnMonad, TcRnTypes)
        These two replace TcMonad and RnMonad
      
      * Give them a single 'driver' (TcRnDriver).  This driver
        replaces TcModule.lhs and Rename.lhs
      
      * The haskell-src library package has a module
      	Language/Haskell/THSyntax
        which defines the Haskell data type seen by the TH programmer.
      
      * New modules:
      	hsSyn/Convert.hs 	converts THSyntax -> HsSyn
      	deSugar/DsMeta.hs 	converts HsSyn -> THSyntax
      
      * New module typecheck/TcSplice type-checks Template Haskell splices.
      
      		-------------
      		Linking stuff
      		-------------
      
      * ByteCodeLink has been split into
      	ByteCodeLink	(which links)
      	ByteCodeAsm	(which assembles)
      
      * New module ghci/ObjLink is the object-code linker.
      
      * compMan/CmLink is removed entirely (was out of place)
        Ditto CmTypes (which was tiny)
      
      * Linker.c initialises the linker when it is first used (no need to call
        initLinker any more).  Template Haskell makes it harder to know when
        and whether to initialise the linker.
      
      
      	-------------------------------------
      	Gathering the LIE in the type checker
      	-------------------------------------
      
      * Instead of explicitly gathering constraints in the LIE
      	tcExpr :: RenamedExpr -> TcM (TypecheckedExpr, LIE)
        we now dump the constraints into a mutable varabiable carried
        by the monad, so we get
      	tcExpr :: RenamedExpr -> TcM TypecheckedExpr
      
        Much less clutter in the code, and more efficient too.
        (Originally suggested by Mark Shields.)
      
      
      		-----------------
      		Remove "SysNames"
      		-----------------
      
      Because the renamer and the type checker were entirely separate,
      we had to carry some rather tiresome implicit binders (or "SysNames")
      along inside some of the HsDecl data structures.  They were both
      tiresome and fragile.
      
      Now that the typechecker and renamer are more intimately coupled,
      we can eliminate SysNames (well, mostly... default methods still
      carry something similar).
      
      		-------------
      		Clean up HsPat
      		-------------
      
      One big clean up is this: instead of having two HsPat types (InPat and
      OutPat), they are now combined into one.  This is more consistent with
      the way that HsExpr etc is handled; there are some 'Out' constructors
      for the type checker output.
      
      So:
      	HsPat.InPat	--> HsPat.Pat
      	HsPat.OutPat	--> HsPat.Pat
      	No 'pat' type parameter in HsExpr, HsBinds, etc
      
      	Constructor patterns are nicer now: they use
      		HsPat.HsConDetails
      	for the three cases of constructor patterns:
      		prefix, infix, and record-bindings
      
      	The *same* data type HsConDetails is used in the type
      	declaration of the data type (HsDecls.TyData)
      
      Lots of associated clean-up operations here and there.  Less code.
      Everything is wonderful.
      9af77fa4
  12. 10 Sep, 2002 1 commit
  13. 06 Sep, 2002 2 commits
    • simonmar's avatar
      [project @ 2002-09-06 14:34:13 by simonmar] · 77186ef4
      simonmar authored
      Partial rewrite of the POSIX library.
      
      The main purpose of this sweep is to remove the last dependencies of
      the compiler on hslibs.  When I've committed the associated compiler
      changes, only the 'base' package will be required to bootstrap the
      compiler.  Additionally to build GHCi, the 'readline' and 'unix'
      packages will be required.
      
      The new POSIX library lives mostly in libraries/unix, with a few bits
      required for compiler bootstrapping in libraries/base.  The 'base'
      package is mostly free of hsc2hs code to make bootstrapping from HC
      files easier, but the 'unix' package will use hsc2hs liberally.
      
      The old POSIX library continues to provide more-or-less the same
      interface as before, although some of the types are more correct now
      (previously lots of POSIX types were just mapped to Int).  The new
      interface is largely the same as the old, except that some new
      functionality from the latest POSIX spec has been added (eg. symbolic
      links).
      
      So far, the new POSIX library has signal support, directory/file
      operations and lots of stuff from unistd.h.  The module names are:
      
        System.Posix
      	The main dude, exports everything
      
        System.Posix.Types
      	All the POSIX types, using the same naming scheme as
              Foreign.C.Types, Eg. CUid, COff, etc.  Many of these types
              were previously exported by GHC.Posix.
      
              Additionally exports the "nicer" names used by the old POSIX
      	library for compatibility (eg. ProcessID == CPid, FileMode ==
      	CMode, etc.)
      
      	All reasonable instances are derived for these types.
      
        System.Posix.Signals
      	Signal support, contains most of which was in PosixProcPrim before.
      	The RTS interface to the signal handling support has been
      	rationalised slightly.
      
        System.Posix.Directory
       	Directory support, most were in PosixFiles before.
      
        System.Posix.Files
      	File operations, most were in PosixFiles before.
      
        System.Posix.Unistd
      	(for want of a better name) Miscellaneous bits that mostly come
      	from the unistd.h header file.  PosixProcEnv before.
      
      The rest of the library should pan out like so:
      
        System.Posix.IO
        System.Posix.Error   (maybe)
        System.Posix.Process
        System.Posix.Terminal
      
      (I've no doubt broken Win32 support, but I'm checking the build at the moment).
      77186ef4
    • simonmar's avatar
      [project @ 2002-09-06 09:56:12 by simonmar] · f8e722a4
      simonmar authored
      Selector Thunk Fix, take II.
      
      The previous version didn't deal well with selector thunks which point
      to more selector thunks, and on closer inspection the method was
      flawed.  Now I've introduced a function
      
      	StgClosure *eval_selector_thunk( int field, StgClosure * )
      
      which evaluates a selector thunk returning its value, in from-space,
      if possible.  It blackholes the thunk during evaluation.  It might
      recursively evaluate more selector thunks, but it does this in a
      bounded way and updates the thunks with indirections (NOT forwarding
      pointers) after evaluation.
      
      This cleans things up somewhat, and I believe it deals properly with
      both types of selector-thunk loops that arise.
      
      MERGE TO STABLE
      f8e722a4
  14. 05 Sep, 2002 2 commits
    • simonmar's avatar
      [project @ 2002-09-05 16:26:33 by simonmar] · 8435b2e4
      simonmar authored
      Fix for infinite loop when there is a THUNK_SELECTOR which eventually
      refers to itself, such as might be generated by code like
      
      	let x = (fst x, snd x) in ...
      
      At the same time, I re-enabled the code to traverse multiple selector
      thunks with bounded depth, because I believe it now works.
      
      MERGE TO STABLE (but test thoroughly in the HEAD first, this is
      fragile stuff)
      8435b2e4
    • simonmar's avatar
      [project @ 2002-09-05 08:58:55 by simonmar] · ed6e7225
      simonmar authored
      Remove RtsAPIDeprec.c, since this is causing grief.  The upshot (I
      think) is that you won't be able to do foreign import "wrapper" with
      an Addr in the type.
      ed6e7225
  15. 03 Sep, 2002 1 commit
  16. 28 Aug, 2002 1 commit
  17. 19 Aug, 2002 2 commits
  18. 16 Aug, 2002 3 commits
  19. 09 Aug, 2002 3 commits
  20. 05 Aug, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-08-05 10:11:03 by simonmar] · 3c5a4f17
      simonmar authored
      Overhaul the debugging flags.  The old bitfield mechanism was a bit
      silly, so now instead of writing -D129 (the one I use most) you can
      now write -DSs.  Each debugging option has a single character assigned
      to it, documented in the -? help text.
      3c5a4f17
  21. 28 Jul, 2002 1 commit
  22. 26 Jul, 2002 1 commit
  23. 25 Jul, 2002 1 commit
    • sof's avatar
      [project @ 2002-07-25 18:36:59 by sof] · d9d8ab15
      sof authored
      Expose printAllThreads() in non-DEBUG builds;
      of some use when debugging ConcHask code and
      want a dump of the current state of the system's
      threads.
      
      Not provided via a library, so to use, do
      
       foreign import call unsafe printAllThreads :: IO ()
      d9d8ab15
  24. 24 Jul, 2002 2 commits
    • sof's avatar
      [project @ 2002-07-24 18:18:13 by sof] · dd0f4129
      sof authored
      warning removal
      dd0f4129
    • sof's avatar
      [project @ 2002-07-24 03:38:58 by sof] · 126ebbae
      sof authored
      awaitEvent: if select() reports EBADF,
      always unblock all waiting threads, even if
      the prior invocation of select() also
      elicited an EBADF.
      
      The 'smart' that was there previously runs
      the risk of working against us (if the EBADFs are
      coming from different fds), so the above
      scheme is preferable (and simpler.)
      126ebbae
  25. 19 Jul, 2002 3 commits
    • sof's avatar
      [project @ 2002-07-19 18:45:21 by sof] · 0974f1a8
      sof authored
      forkProcess():
       be less ambitious, and don't kill any main_threads.
       Killing them, and possibly replacing them on the
       main_threads with the current one, turned out to
       run into problems of its own (see comments.)
      
       The hope/wish is that the current behaviour of
       forkProcess will suffice.
      0974f1a8
    • simonmar's avatar
      [project @ 2002-07-19 11:47:30 by simonmar] · 5926dc51
      simonmar authored
      Code to make the general case of createAdjustor() work on Sparc, from
      Sven Panne.  Previously only 4 args were supported.
      5926dc51
    • sof's avatar
      [project @ 2002-07-19 00:06:05 by sof] · 180e628b
      sof authored
      forkProcess():
       - fix bug which left run_queue_tl in a bad state.
       - be better behaved wrt 'main threads', i.e.,
         if the killing thread isn't the main thread,
         make sure it's hooked up to main_threads +
         correctly signal the completion/killing of
         any main threads.
      180e628b