[commit: ghc] ghc-7.8: fix comment on allocate() (#8254) (c2ef200)

git at git.haskell.org git at git.haskell.org
Fri Feb 28 23:39:18 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.8
Link       : http://ghc.haskell.org/trac/ghc/changeset/c2ef200e501157a70acc76b9708f2d1c2e96cc8a/ghc

>---------------------------------------------------------------

commit c2ef200e501157a70acc76b9708f2d1c2e96cc8a
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Thu Feb 27 12:37:32 2014 +0000

    fix comment on allocate() (#8254)
    
    (cherry picked from commit 68c0d8689dd93cb0ce74a288e82f2ed997c31acc)


>---------------------------------------------------------------

c2ef200e501157a70acc76b9708f2d1c2e96cc8a
 rts/sm/Storage.c |   26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c
index df5f4b3..86bd1c2 100644
--- a/rts/sm/Storage.c
+++ b/rts/sm/Storage.c
@@ -662,20 +662,22 @@ move_STACK (StgStack *src, StgStack *dest)
 }
 
 /* -----------------------------------------------------------------------------
-   allocate()
-
-   This allocates memory in the current thread - it is intended for
-   use primarily from STG-land where we have a Capability.  It is
-   better than allocate() because it doesn't require taking the
-   sm_mutex lock in the common case.
-
-   Memory is allocated directly from the nursery if possible (but not
-   from the current nursery block, so as not to interfere with
-   Hp/HpLim).
+   StgPtr allocate (Capability *cap, W_ n)
+
+   Allocates an area of memory n *words* large, from the nursery of
+   the supplied Capability, or from the global block pool if the area
+   requested is larger than LARGE_OBJECT_THRESHOLD.  Memory is not
+   allocated from the current nursery block, so as not to interfere
+   with Hp/HpLim.
+
+   The address of the allocated memory is returned. allocate() never
+   fails; if it returns, the returned value is a valid address.  If
+   the nursery is already full, then another block is allocated from
+   the global block pool.  If we need to get memory from the OS and
+   that operation fails, then the whole process will be killed.
    -------------------------------------------------------------------------- */
 
-StgPtr
-allocate (Capability *cap, W_ n)
+StgPtr allocate (Capability *cap, W_ n)
 {
     bdescr *bd;
     StgPtr p;



More information about the ghc-commits mailing list