Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex D
GHC
Commits
89487be2
Commit
89487be2
authored
Aug 14, 2019
by
Ömer Sinan Ağacan
Committed by
Marge Bot
Aug 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some tweaks in GHC.Compact haddocks
parent
10763ce0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
14 deletions
+17
-14
libraries/ghc-compact/GHC/Compact.hs
libraries/ghc-compact/GHC/Compact.hs
+17
-14
No files found.
libraries/ghc-compact/GHC/Compact.hs
View file @
89487be2
...
...
@@ -102,14 +102,13 @@ import GHC.Types
-- it; if you have data that lives in two 'Compact's, each will have a
-- separate copy of the data.
--
-- The cost of compaction is similar to the cost of GC for the same
-- data, but it is performed only once. However, because
-- "GHC.Compact.compact" does not stop-the-world, retaining internal
-- sharing during the compaction process is very costly. The user
-- can choose whether to 'compact' or 'compactWithSharing'.
-- The cost of compaction is fully evaluating the data + copying it. However,
-- because 'compact' does not stop-the-world, retaining internal sharing during
-- the compaction process is very costly. The user can choose whether to
-- 'compact' or 'compactWithSharing'.
--
-- When you have a @'Compact' a@, you can get a pointer to the actual object
-- in the region using
"GHC.Compact.getCompact"
. The 'Compact' type
-- in the region using
'getCompact'
. The 'Compact' type
-- serves as handle on the region itself; you can use this handle
-- to add data to a specific 'Compact' with 'compactAdd' or
-- 'compactAddWithSharing' (giving you a new handle which corresponds
...
...
@@ -134,7 +133,7 @@ import GHC.Types
-- 'GHC.Array.MutableArray') also cannot be compacted, because subsequent
-- mutation would destroy the property that a compact is self-contained.
--
-- If compaction encounters any of the above, a 'CompactionFailed'
-- If compaction encounters any of the above, a 'Co
ntrol.Exception.Co
mpactionFailed'
-- exception will be thrown by the compaction operation.
--
data
Compact
a
=
Compact
Compact
#
a
(
MVar
()
)
...
...
@@ -155,12 +154,16 @@ mkCompact compact# a s =
where
unIO
(
IO
a
)
=
a
-- | Transfer @a@ into a new compact region, with a preallocated size,
-- possibly preserving sharing or not. If you know how big the data
-- structure in question is, you can save time by picking an appropriate
-- block size for the compact region.
--
compactSized
::
Int
->
Bool
->
a
->
IO
(
Compact
a
)
-- | Transfer @a@ into a new compact region, with a preallocated size (in
-- bytes), possibly preserving sharing or not. If you know how big the data
-- structure in question is, you can save time by picking an appropriate block
-- size for the compact region.
--
compactSized
::
Int
-- ^ Size of the compact region, in bytes
->
Bool
-- ^ Whether to retain internal sharing
->
a
->
IO
(
Compact
a
)
compactSized
(
I
#
size
)
share
a
=
IO
$
\
s0
->
case
compactNew
#
(
int2Word
#
size
)
s0
of
{
(
#
s1
,
compact
#
#
)
->
case
compactAddPrim
compact
#
a
s1
of
{
(
#
s2
,
pk
#
)
->
...
...
@@ -254,7 +257,7 @@ compactSize :: Compact a -> IO Word
compactSize
(
Compact
buffer
_
lock
)
=
withMVar
lock
$
\
_
->
IO
$
\
s0
->
case
compactSize
#
buffer
s0
of
(
#
s1
,
sz
#
)
->
(
#
s1
,
W
#
sz
#
)
-- |
*Experimental.*
This function doesn't actually resize a compact
-- |
__Experimental__
This function doesn't actually resize a compact
-- region; rather, it changes the default block size which we allocate
-- when the current block runs out of space, and also appends a block
-- to the compact region.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment