[Git][ghc/ghc][wip/T23210] 2 commits: StgToByteCode: Don't assume that data con workers are nullary

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Mon May 15 21:38:09 UTC 2023



Ben Gamari pushed to branch wip/T23210 at Glasgow Haskell Compiler / GHC


Commits:
30c45ecf by Ben Gamari at 2023-05-15T17:37:34-04:00
StgToByteCode: Don't assume that data con workers are nullary

Previously StgToByteCode assumed that all data-con workers were of a
nullary representation. This is not a valid assumption, as seen
in #23210, where an unsaturated application of a unary data
constructor's worker resulted in invalid bytecode. Sadly, I have not yet
been able to reduce a minimal testcase for this.

Fixes #23210.

- - - - -
204c825f by Ben Gamari at 2023-05-15T17:37:38-04:00
StgToByteCode: Fix handling of Addr# literals

Previously we assumed that all unlifted types were Addr#.

- - - - -


2 changed files:

- compiler/GHC/StgToByteCode.hs
- rts/Interpreter.c


Changes:

=====================================
compiler/GHC/StgToByteCode.hs
=====================================
@@ -1820,14 +1820,11 @@ pushAtom d p (StgVarArg var)
         -- PUSH_G doesn't tag constructors. So we use PACK here
         -- if we are dealing with nullary constructor.
         case isDataConWorkId_maybe var of
-          Just con -> do
-            massert (isNullaryRepDataCon con)
-            return (unitOL (PACK con 0), szb)
+          Just con | isNullaryRepDataCon con -> do
+              return (unitOL (PACK con 0), szb)
 
-          Nothing
             -- see Note [Generating code for top-level string literal bindings]
-            | isUnliftedType (idType var) -> do
-              massert (idType var `eqType` addrPrimTy)
+          _ | idType var `eqType` addrPrimTy ->
               return (unitOL (PUSH_ADDR (getName var)), szb)
 
             | otherwise -> do


=====================================
rts/Interpreter.c
=====================================
@@ -1687,7 +1687,6 @@ run_BCO:
             // n_nptrs=1, n_ptrs=0.
             ASSERT(n_ptrs + n_nptrs == n_words || (n_nptrs == 1 && n_ptrs == 0));
             ASSERT(n_ptrs + n_nptrs > 0);
-            //ASSERT(n_words > 0); // We shouldn't ever need to allocate nullary constructors
             for (int i = 0; i < n_words; i++) {
                 con->payload[i] = (StgClosure*)SpW(i);
             }



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6b51e51e8c2e617ecfcc54957d8cfeda0f62e82c...204c825fdc937c99371c330c6d56d2cf69fa7e42

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6b51e51e8c2e617ecfcc54957d8cfeda0f62e82c...204c825fdc937c99371c330c6d56d2cf69fa7e42
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/20230515/7918712e/attachment-0001.html>


More information about the ghc-commits mailing list