[commit: ghc] ghc-7.10: Groom comments related to StaticPointers. (2accf97)
git at git.haskell.org
git at git.haskell.org
Tue Dec 23 14:56:18 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-7.10
Link : http://ghc.haskell.org/trac/ghc/changeset/2accf975340fdd07c6074c9aaf20f607f7c2ae19/ghc
>---------------------------------------------------------------
commit 2accf975340fdd07c6074c9aaf20f607f7c2ae19
Author: Facundo Domínguez <facundo.dominguez at tweag.io>
Date: Mon Dec 22 19:15:36 2014 -0200
Groom comments related to StaticPointers.
Reviewed By: austin
Differential Revision: https://phabricator.haskell.org/D575
(cherry picked from commit c72f61c6d4dd779d61bd0ebc0b1211a84c5b9038)
>---------------------------------------------------------------
2accf975340fdd07c6074c9aaf20f607f7c2ae19
compiler/deSugar/StaticPtrTable.hs | 5 ++---
compiler/rename/RnExpr.hs | 2 +-
docs/users_guide/glasgow_exts.xml | 6 ++----
includes/rts/StaticPtrTable.h | 3 +--
rts/Hash.c | 2 +-
rts/Hash.h | 2 +-
testsuite/tests/rts/GcStaticPointers.hs | 12 ++++++------
testsuite/tests/th/TH_StaticPointers02.hs | 4 +---
testsuite/tests/th/TH_StaticPointers02.stderr | 2 +-
9 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/compiler/deSugar/StaticPtrTable.hs b/compiler/deSugar/StaticPtrTable.hs
index d4cad0e..858a0e8 100644
--- a/compiler/deSugar/StaticPtrTable.hs
+++ b/compiler/deSugar/StaticPtrTable.hs
@@ -24,8 +24,7 @@
-- >
-- > }
--
--- where constants are values of a fingerprint of the string
--- "<package_id>:<module_name>.sptEntry:<N>"
+-- where the constants are fingerprints produced from the static forms.
--
module StaticPtrTable (sptInitCode) where
@@ -38,7 +37,7 @@ import GHC.Fingerprint
-- | @sptInitCode module statics@ is a C stub to insert the static entries
--- @statics@ of @module@ into the static pointer table
+-- @statics@ of @module@ into the static pointer table.
--
-- Each entry contains the fingerprint used to locate the entry and the
-- top-level binding for the entry.
diff --git a/compiler/rename/RnExpr.hs b/compiler/rename/RnExpr.hs
index 4755547..cf5457e 100644
--- a/compiler/rename/RnExpr.hs
+++ b/compiler/rename/RnExpr.hs
@@ -313,7 +313,7 @@ rnExpr e@(ELazyPat {}) = patSynErr e
For the static form we check that the free variables are all top-level
value bindings. This is done by checking that the name is external or
-wired-in. See the Note about the NameSorts in Name.lhs.
+wired-in. See the Notes about the NameSorts in Name.hs.
-}
rnExpr e@(HsStatic expr) = do
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml
index a717b72..44577f9 100644
--- a/docs/users_guide/glasgow_exts.xml
+++ b/docs/users_guide/glasgow_exts.xml
@@ -10470,9 +10470,6 @@ While the following definitions are rejected:
ref6 = let x = 1 in static x
ref7 y = static (let x = 1 in y)
</programlisting>
-Note that currently, the body <literal>e</literal> in <literal>static
-e</literal> is restricted to a single identifier when at the GHCi
-prompt.
</para>
</sect2>
@@ -10502,13 +10499,14 @@ That being said, with the appropriate use of wrapper datatypes, the
above limitations induce no loss of generality:
<programlisting>
{-# LANGUAGE ConstraintKinds #-}
-{-# LANGUAGE DerivingDataTypeable #-}
+{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE StaticPointers #-}
import Control.Monad.ST
+import Data.Typeable
import GHC.StaticPtr
data Dict c = c => Dict
diff --git a/includes/rts/StaticPtrTable.h b/includes/rts/StaticPtrTable.h
index 8b56510..87a905c 100644
--- a/includes/rts/StaticPtrTable.h
+++ b/includes/rts/StaticPtrTable.h
@@ -17,8 +17,7 @@
/** Inserts an entry in the Static Pointer Table.
*
* The key is a fingerprint computed from the StaticName of a static pointer
- * and the spe_closure is a pointer to the closure defining the table entry
- * (GHC.SptEntry).
+ * and the spe_closure is a pointer to the closure defining the table entry.
*
* A stable pointer to the closure is made to prevent it from being garbage
* collected while the entry exists on the table.
diff --git a/rts/Hash.c b/rts/Hash.c
index 1881092..422c3d9 100644
--- a/rts/Hash.c
+++ b/rts/Hash.c
@@ -206,7 +206,7 @@ lookupHashTable(HashTable *table, StgWord key)
return NULL;
}
-// Puts up to keys_sz keys of the hash table into the given array. Returns the
+// Puts up to szKeys keys of the hash table into the given array. Returns the
// actual amount of keys that have been retrieved.
//
// If the table is modified concurrently, the function behavior is undefined.
diff --git a/rts/Hash.h b/rts/Hash.h
index e802644..136f94a 100644
--- a/rts/Hash.h
+++ b/rts/Hash.h
@@ -21,7 +21,7 @@ void * removeHashTable ( HashTable *table, StgWord key, void *data );
int keyCountHashTable (HashTable *table);
-// Puts up to keys_sz keys of the hash table into the given array. Returns the
+// Puts up to szKeys keys of the hash table into the given array. Returns the
// actual amount of keys that have been retrieved.
//
// If the table is modified concurrently, the function behavior is undefined.
diff --git a/testsuite/tests/rts/GcStaticPointers.hs b/testsuite/tests/rts/GcStaticPointers.hs
index 7c2fc2b..c498af5 100644
--- a/testsuite/tests/rts/GcStaticPointers.hs
+++ b/testsuite/tests/rts/GcStaticPointers.hs
@@ -14,9 +14,9 @@ import Unsafe.Coerce (unsafeCoerce)
nats :: [Integer]
nats = [0 .. ]
--- Just a StaticPtr to some CAF so that we can deRef it.
-nats_fp :: StaticKey
-nats_fp = staticKey (static nats :: StaticPtr [Integer])
+-- The key of a 'StaticPtr' to some CAF.
+nats_key :: StaticKey
+nats_key = staticKey (static nats :: StaticPtr [Integer])
main = do
let z = nats !! 400
@@ -26,8 +26,8 @@ main = do
print z
performGC
threadDelay 1000000
- let Just p = unsafeLookupStaticPtr nats_fp
+ let Just p = unsafeLookupStaticPtr nats_key
print (deRefStaticPtr (unsafeCoerce p) !! 800 :: Integer)
- -- Uncommenting the next line keeps primes alive and would prevent a segfault
- -- if nats were garbage collected.
+ -- Uncommenting the next line keeps 'nats' alive and would prevent a segfault
+ -- if 'nats' were garbage collected.
-- print (nats !! 900)
diff --git a/testsuite/tests/th/TH_StaticPointers02.hs b/testsuite/tests/th/TH_StaticPointers02.hs
index 1f619a7..b381050 100644
--- a/testsuite/tests/th/TH_StaticPointers02.hs
+++ b/testsuite/tests/th/TH_StaticPointers02.hs
@@ -1,9 +1,7 @@
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StaticPointers #-}
--- | A test to try the static form in splices.
---
--- A static form is defined in a splice and then it is used in the program.
+-- | A test to try the static form in splices, which should fail.
--
module Main(main) where
diff --git a/testsuite/tests/th/TH_StaticPointers02.stderr b/testsuite/tests/th/TH_StaticPointers02.stderr
index cc6fa82..88da9d1 100644
--- a/testsuite/tests/th/TH_StaticPointers02.stderr
+++ b/testsuite/tests/th/TH_StaticPointers02.stderr
@@ -1,5 +1,5 @@
-TH_StaticPointers02.hs:13:34:
+TH_StaticPointers02.hs:11:34:
static forms cannot be used in splices: static 'a'
In the splice:
$(case staticKey (static 'a') of {
More information about the ghc-commits
mailing list