Skip to content

Instantly share code, notes, and snippets.

@TerrorJack
Created August 30, 2022 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TerrorJack/b497b6c2e903638384a4eba0dd809895 to your computer and use it in GitHub Desktop.
Save TerrorJack/b497b6c2e903638384a4eba0dd809895 to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedStrings #-}
import Data.List
import qualified Data.Map.Strict as M
import qualified Data.Text as T
main :: IO ()
main = do
s <- readFile "rts/include/stg/MiscClosures.h"
let toks =
foldl'
(\acc (f, x) -> M.insertWith (<>) f [x] acc)
M.empty
[ (f, x) | l <- lines s, let toks = words l, not (null toks), let tok = T.pack $ head toks, "RTS_" `T.isPrefixOf` tok, let f : x : _ = T.split (`elem` ['(', ')']) tok
]
print $
sort $
[ "enterFunCCS",
"pushCostCentre",
"updateRemembSetPushClosure_",
"updateRemembSetPushThunk_",
"stg_copyArray_barrier"
]
<> toks M.! "RTS_FUN_DECL"
<> [x <> "_ret" | x <- toks M.! "RTS_RET"]
<> [ x <> "_entry"
| x <-
toks M.! "RTS_ENTRY" <> toks M.! "RTS_FUN" <> toks M.! "RTS_THUNK"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment