Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gesh
GHC
Commits
ba84292a
Commit
ba84292a
authored
26 years ago
by
Simon Marlow
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 1999-02-11 17:54:36 by simonm]
finalise/finalize changes.
parent
63015c7f
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ghc/lib/misc/Memo.lhs
+7
-7
7 additions, 7 deletions
ghc/lib/misc/Memo.lhs
ghc/lib/misc/SocketPrim.lhs
+2
-2
2 additions, 2 deletions
ghc/lib/misc/SocketPrim.lhs
with
9 additions
and
9 deletions
ghc/lib/misc/Memo.lhs
+
7
−
7
View file @
ba84292a
% $Id: Memo.lhs,v 1.
1
1999/02/
03
1
6
:54:
02
simonm Exp $
% $Id: Memo.lhs,v 1.
2
1999/02/
11
1
7
:54:
36
simonm Exp $
%
% (c) The GHC Team, 1999
%
...
...
@@ -32,7 +32,7 @@ It's important that we can garbage collect old entries in the table
when the key is no longer reachable in the heap. Hence the value part
of each table entry is (Weak val), where the weak pointer "key" is the
key for our memo table, and 'val' is the value of this memo table
entry. When the key becomes unreachable, a finali
s
er will fire and
entry. When the key becomes unreachable, a finali
z
er will fire and
remove this entry from the hash bucket, and further attempts to
dereference the weak pointer will return Nothing. References from
'val' to the key are ignored (see the semantics of weak pointers in
...
...
@@ -47,14 +47,14 @@ type MemoTable key val
\end{code}
We use an MVar to the hash table, so that several threads may safely
access it concurrently. This includes the finali
s
ation threads that
access it concurrently. This includes the finali
z
ation threads that
remove entries from the table.
ToDo: make the finali
s
ers refer to the memo table only through a weak
ToDo: make the finali
z
ers refer to the memo table only through a weak
pointer, because otherwise the memo table will keep itself alive
(i.e. even after the function is dead, the weak pointers in the memo
table stay alive because their keys are alive, and hence the values
and finali
s
ers are alive, therefore the table itself stays alive.
and finali
z
ers are alive, therefore the table itself stays alive.
Bad).
\begin{code}
...
...
@@ -84,12 +84,12 @@ memo' f ref = \x -> unsafePerformIO $ do
return result
Nothing -> do
let result = f x
weak <- mkWeak x result finali
s
er
weak <- mkWeak x result
(Just
finali
z
er
)
writeIOArray table hash_key ((stable_key,weak):bucket)
putMVar ref (size,table)
return result
where finali
s
er = do
where finali
z
er = do
(size,table) <- takeMVar ref
bucket <- readIOArray table hash_key
let new_bucket = [ (sn,weak)
...
...
This diff is collapsed.
Click to expand it.
ghc/lib/misc/SocketPrim.lhs
+
2
−
2
View file @
ba84292a
...
...
@@ -82,7 +82,7 @@ module SocketPrim (
import GlaExts
import ST
import Ix
import Weak ( addForeignFinali
s
er )
import Weak ( addForeignFinali
z
er )
import PrelIOBase -- IOError, Handle representation
import PrelHandle
import Foreign
...
...
@@ -1206,7 +1206,7 @@ socketToHandle :: Socket -> IOMode -> IO Handle
socketToHandle (MkSocket fd _ _ _ _) m = do
fileobj <- _ccall_ openFd fd (file_mode::Int) (flush_on_close::Int)
fo <- makeForeignObj fileobj
addForeignFinali
s
er fo (freeFileObject fo)
addForeignFinali
z
er fo (freeFileObject fo)
mkBuffer__ fo 0 -- not buffered
hndl <- newHandle (Handle__ fo htype NoBuffering socket_str)
return hndl
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment