[Git][ghc/ghc][wip/js-rts-fixmes] JS RTS: use nFieldCache for closureConstructors

Josh Meredith (@JoshMeredith) gitlab at gitlab.haskell.org
Tue Feb 7 13:28:28 UTC 2023



Josh Meredith pushed to branch wip/js-rts-fixmes at Glasgow Haskell Compiler / GHC


Commits:
95801b53 by Josh Meredith at 2023-02-07T13:28:16+00:00
JS RTS: use nFieldCache for closureConstructors

- - - - -


2 changed files:

- compiler/GHC/JS/Make.hs
- compiler/GHC/StgToJS/Rts/Rts.hs


Changes:

=====================================
compiler/GHC/JS/Make.hs
=====================================
@@ -133,6 +133,7 @@ module GHC.JS.Make
   , clsName
   , dataFieldName, dataFieldNames
   , varName, varNames
+  , nFieldCache
   )
 where
 
@@ -645,7 +646,7 @@ dataFieldCache :: Array Int FastString
 dataFieldCache = listArray (0,nFieldCache) (map (mkFastString . ('d':) . show) [(0::Int)..nFieldCache])
 
 nFieldCache :: Int
-nFieldCache  = 16384
+nFieldCache  = 24
 
 dataFieldName :: Int -> FastString
 dataFieldName i
@@ -658,39 +659,39 @@ dataFieldNames = fmap dataFieldName [1..nFieldCache]
 
 -- | Cache "h$dXXX" names
 dataCache :: Array Int FastString
-dataCache = listArray (0,63) (map (mkFastString . ("h$d"++) . show) [(0::Int)..63])
+dataCache = listArray (0,nFieldCache) (map (mkFastString . ("h$d"++) . show) [(0::Int)..nFieldCache])
 
 dataName :: Int -> FastString
 dataName i
-  | i < 0 || i > 63 = panic "dataCacheName" (ppr i)
-  | otherwise       = dataCache ! i
+  | i < 0 || i > nFieldCache = panic "dataCacheName" (ppr i)
+  | otherwise                = dataCache ! i
 
 allocData :: Int -> JExpr
 allocData i = toJExpr (TxtI (dataCache ! i))
 
 -- | Cache "h$cXXX" names
 clsCache :: Array Int FastString
-clsCache = listArray (0,63) (map (mkFastString . ("h$c"++) . show) [(0::Int)..63])
+clsCache = listArray (0,nFieldCache) (map (mkFastString . ("h$c"++) . show) [(0::Int)..nFieldCache])
 
 clsName :: Int -> FastString
 clsName i
-  | i < 0 || i > 63 = panic "clsCacheName" (ppr i)
-  | otherwise       = clsCache ! i
+  | i < 0 || i > nFieldCache = panic "clsCacheName" (ppr i)
+  | otherwise                = clsCache ! i
 
 allocClsA :: Int -> JExpr
 allocClsA i = toJExpr (TxtI (clsCache ! i))
 
 -- | Cache "xXXX" names
 varCache :: Array Int FastString
-varCache = listArray (0,63) (map (mkFastString . ('x':) . show) [(0::Int)..63])
+varCache = listArray (0,nFieldCache) (map (mkFastString . ('x':) . show) [(0::Int)..nFieldCache])
 
 varName :: Int -> Ident
 varName i
-  | i < 0 || i > 63 = panic "varCacheName" (ppr i)
-  | otherwise       = TxtI $ varCache ! i
+  | i < 0 || i > nFieldCache = panic "varCacheName" (ppr i)
+  | otherwise                = TxtI $ varCache ! i
 
 varNames :: [Ident]
-varNames = fmap varName [1..63]
+varNames = fmap varName [1..nFieldCache]
 
 
 --------------------------------------------------------------------------------


=====================================
compiler/GHC/StgToJS/Rts/Rts.hs
=====================================
@@ -81,8 +81,8 @@ resetResultVar r = toJExpr r |= null_
 -- JIT can optimize better.
 closureConstructors :: StgToJSConfig -> JStat
 closureConstructors s = BlockStat
-  [ mconcat (map mkClosureCon (Nothing : map Just [0..24]))
-  , mconcat (map mkDataFill [1..24])
+  [ mconcat (map mkClosureCon (Nothing : map Just [0..nFieldCache]))
+  , mconcat (map mkDataFill [1..nFieldCache])
   ]
   where
     prof = csProf s



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/95801b5384f4ee166ca5ceb84cfc905caca5f65e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/95801b5384f4ee166ca5ceb84cfc905caca5f65e
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230207/fd404c87/attachment-0001.html>


More information about the ghc-commits mailing list