Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Glasgow Haskell Compiler
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
Shayne Fletcher
Glasgow Haskell Compiler
Commits
279ac9f6
Commit
279ac9f6
authored
Jul 04, 2013
by
nfrisby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
copy the plugin's FastStringTable changes back into the host compiler
parent
163de258
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
5 deletions
+26
-5
compiler/simplCore/CoreMonad.lhs
compiler/simplCore/CoreMonad.lhs
+12
-1
compiler/simplCore/SimplCore.lhs
compiler/simplCore/SimplCore.lhs
+2
-2
compiler/utils/FastString.lhs
compiler/utils/FastString.lhs
+12
-2
No files found.
compiler/simplCore/CoreMonad.lhs
View file @
279ac9f6
...
...
@@ -44,7 +44,7 @@ module CoreMonad (
liftIO1, liftIO2, liftIO3, liftIO4,
-- ** Global initialization
reinitializeGlobals,
reinitializeGlobals,
bracketGlobals,
-- ** Dealing with annotations
getAnnotations, getFirstAnnotations,
...
...
@@ -947,6 +947,7 @@ domain of the GlobalRdrEnv is affected by the RdrName's OccName's FastString's
unique.
\begin{code}
-- called by plugin
reinitializeGlobals :: CoreM ()
reinitializeGlobals = do
(sf_globals, fs_table, linker_globals) <- read cr_globals
...
...
@@ -956,6 +957,16 @@ reinitializeGlobals = do
liftIO $ restoreFSTable fs_table
liftIO $ restoreLinkerGlobals linker_globals
liftIO $ setUnsafeGlobalDynFlags dflags
-- called by host compiler, assuming argument is code from a plugin
bracketGlobals :: CoreM a -> CoreM a
bracketGlobals (CoreM f) = do
tbl <- liftIO saveFSTable
let upd e = e {cr_globals=(x,tbl,z)}
where (x,_,z) = cr_globals e
x <- CoreM (\s -> updEnv upd (f s))
liftIO unsaveFSTable
return x
\end{code}
%************************************************************************
...
...
compiler/simplCore/SimplCore.lhs
View file @
279ac9f6
...
...
@@ -311,7 +311,7 @@ addPluginPasses dflags builtin_passes
; foldM query_plug builtin_passes named_plugins }
where
query_plug todos (mod_nm, plug)
= installCoreToDos plug options todos
=
bracketGlobals $
installCoreToDos plug options todos
where
options = [ option | (opt_mod_nm, option) <- pluginModNameOpts dflags
, opt_mod_nm == mod_nm ]
...
...
@@ -407,7 +407,7 @@ doCorePass _ CoreDoNothing = return
doCorePass _ (CoreDoPasses passes) = runCorePasses passes
#ifdef GHCI
doCorePass _ (CoreDoPluginPass _ pass) = {-# SCC "Plugin" #-}
pass
doCorePass _ (CoreDoPluginPass _ pass) = {-# SCC "Plugin" #-}
(bracketGlobals . pass)
#endif
doCorePass _ pass = pprPanic "doCorePass" (ppr pass)
...
...
compiler/utils/FastString.lhs
View file @
279ac9f6
...
...
@@ -94,7 +94,7 @@ module FastString
lengthLS,
-- * Saving/restoring globals
saveFSTable, restoreFSTable, FastStringTable
saveFSTable, restoreFSTable,
unsaveFSTable,
FastStringTable
) where
#include "HsVersions.h"
...
...
@@ -480,7 +480,7 @@ nilFS = mkFastString ""
getFastStringTable :: IO [[FastString]]
getFastStringTable = do
tbl <- readIORef string_table
buckets <- mapM (lookupTbl tbl) [0 .. hASH_TBL_SIZE]
buckets <- mapM (lookupTbl tbl) [0 .. hASH_TBL_SIZE
- 1
]
return buckets
-- -----------------------------------------------------------------------------
...
...
@@ -581,9 +581,19 @@ fsLit x = mkFastString x
--------------------
-- for plugins; see Note [Initializing globals] in CoreMonad
-- called by host compiler
saveFSTable :: IO FastStringTable
saveFSTable = readIORef string_table
-- called by host compiler
unsaveFSTable :: IO ()
unsaveFSTable = do
tbl@(FastStringTable _ arr#) <- readIORef string_table
buckets <- mapM (lookupTbl tbl) [0 .. hASH_TBL_SIZE - 1]
let size = sum $ map length $ buckets
writeIORef string_table (FastStringTable size arr#)
-- called by plugin
restoreFSTable :: FastStringTable -> IO ()
restoreFSTable = writeIORef string_table
\end{code}
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