Hannes Siebenhandl pushed to branch wip/fendor/infoprov-id at Glasgow Haskell Compiler / GHC
Commits:
-
58644c6d
by Sylvain Henry at 2025-11-11T14:35:22+01:00
7 changed files:
- libraries/base/tests/all.T
- libraries/ghc-internal/src/GHC/Internal/InfoProv/Types.hsc
- libraries/ghci/GHCi/Message.hs
- testsuite/driver/testlib.py
- testsuite/tests/driver/T20696/all.T
- testsuite/tests/driver/fat-iface/all.T
- testsuite/tests/splice-imports/all.T
Changes:
| ... | ... | @@ -80,7 +80,7 @@ test('length001', |
| 80 | 80 | # excessive amounts of stack space. So we specifically set a low
|
| 81 | 81 | # stack limit and mark it as failing under a few conditions.
|
| 82 | 82 | [extra_run_opts('+RTS -K8m -RTS'),
|
| 83 | - expect_fail_for(['normal', 'threaded1', 'llvm', 'nonmoving', 'nonmoving_thr', 'nonmoving_thr_ghc']),
|
|
| 83 | + expect_fail_for(['normal', 'threaded1', 'llvm', 'nonmoving', 'nonmoving_thr', 'nonmoving_thr_ghc', 'ext-interp']),
|
|
| 84 | 84 | # JS doesn't support stack limit so the test sometimes passes just fine. Therefore the test is
|
| 85 | 85 | # marked as fragile.
|
| 86 | 86 | when(js_arch(), fragile(22921))],
|
| ... | ... | @@ -15,12 +15,13 @@ module GHC.Internal.InfoProv.Types |
| 15 | 15 | , getIPE
|
| 16 | 16 | , StgInfoTable
|
| 17 | 17 | , lookupIPE
|
| 18 | + , lookupIpId
|
|
| 18 | 19 | ) where
|
| 19 | 20 | |
| 20 | 21 | import GHC.Internal.Base
|
| 21 | 22 | import GHC.Internal.Enum
|
| 22 | 23 | import GHC.Internal.Real (fromIntegral)
|
| 23 | -import GHC.Internal.Word (Word32)
|
|
| 24 | +import GHC.Internal.Word (Word32, Word64)
|
|
| 24 | 25 | import GHC.Internal.Show (Show)
|
| 25 | 26 | import GHC.Internal.Ptr (Ptr(..), plusPtr)
|
| 26 | 27 | import GHC.Internal.Foreign.C.String.Encoding (CString, peekCString)
|
| ... | ... | @@ -32,6 +33,8 @@ import GHC.Internal.ClosureTypes |
| 32 | 33 | import GHC.Internal.Prim (whereFrom##)
|
| 33 | 34 | |
| 34 | 35 | data InfoProv = InfoProv {
|
| 36 | + -- | @since base-4.23.0.0
|
|
| 37 | + ipId :: Word64,
|
|
| 35 | 38 | ipName :: String,
|
| 36 | 39 | ipDesc :: ClosureType,
|
| 37 | 40 | ipTyDesc :: String,
|
| ... | ... | @@ -59,6 +62,16 @@ lookupIPE itbl = allocaBytes (#size InfoProvEnt) $ \p -> do |
| 59 | 62 | 1 -> Just `fmap` peekInfoProv (ipeProv p)
|
| 60 | 63 | _ -> return Nothing
|
| 61 | 64 | |
| 65 | +-- | Lookup the stable Id 'ipId' of the 'InfoProv'.
|
|
| 66 | +-- Equivalent to @'fmap' 'ipProvId' <$> 'lookupIPE' ptr@,
|
|
| 67 | +-- but performs fewer lookups.
|
|
| 68 | +lookupIpId :: Ptr StgInfoTable -> IO (Maybe Word64)
|
|
| 69 | +lookupIpId itbl = allocaBytes (#size InfoProvEnt) $ \p -> do
|
|
| 70 | + res <- c_lookupIPE itbl p
|
|
| 71 | + case res of
|
|
| 72 | + 1 -> Just `fmap` peekIpId (ipeProv p)
|
|
| 73 | + _ -> return Nothing
|
|
| 74 | + |
|
| 62 | 75 | getIPE :: a -> r -> (Ptr InfoProvEnt -> IO r) -> IO r
|
| 63 | 76 | getIPE obj fail k = allocaBytes (#size InfoProvEnt) $ \p -> IO $ \s ->
|
| 64 | 77 | case whereFrom## obj (unPtr p) s of
|
| ... | ... | @@ -73,6 +86,9 @@ ipeProv p = (#ptr InfoProvEnt, prov) p |
| 73 | 86 | peekIpDesc :: Ptr InfoProv -> IO Word32
|
| 74 | 87 | peekIpDesc p = (# peek InfoProv, closure_desc) p
|
| 75 | 88 | |
| 89 | +peekIpId :: Ptr InfoProv -> IO Word64
|
|
| 90 | +peekIpId p = (# peek InfoProv, info_prov_id) p
|
|
| 91 | + |
|
| 76 | 92 | peekIpName, peekIpLabel, peekIpUnitId, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString
|
| 77 | 93 | peekIpName p = (# peek InfoProv, table_name) p
|
| 78 | 94 | peekIpLabel p = (# peek InfoProv, label) p
|
| ... | ... | @@ -84,6 +100,7 @@ peekIpTyDesc p = (# peek InfoProv, ty_desc) p |
| 84 | 100 | |
| 85 | 101 | peekInfoProv :: Ptr InfoProv -> IO InfoProv
|
| 86 | 102 | peekInfoProv infop = do
|
| 103 | + provId <- peekIpId infop
|
|
| 87 | 104 | name <- peekCString utf8 =<< peekIpName infop
|
| 88 | 105 | desc <- peekIpDesc infop
|
| 89 | 106 | tyDesc <- peekCString utf8 =<< peekIpTyDesc infop
|
| ... | ... | @@ -93,6 +110,7 @@ peekInfoProv infop = do |
| 93 | 110 | file <- peekCString utf8 =<< peekIpSrcFile infop
|
| 94 | 111 | span <- peekCString utf8 =<< peekIpSrcSpan infop
|
| 95 | 112 | return InfoProv {
|
| 113 | + ipId = provId,
|
|
| 96 | 114 | ipName = name,
|
| 97 | 115 | -- The INVALID_OBJECT case should be impossible as we
|
| 98 | 116 | -- control the C code generating these values.
|
| ... | ... | @@ -545,7 +545,11 @@ instance Binary Heap.ClosureType |
| 545 | 545 | instance Binary Heap.PrimType
|
| 546 | 546 | instance Binary a => Binary (Heap.GenClosure a)
|
| 547 | 547 | instance Binary InfoProv where
|
| 548 | -#if MIN_VERSION_base(4,20,0)
|
|
| 548 | +#if MIN_VERSION_base(4,22,0)
|
|
| 549 | + get = InfoProv <$> get <*> get <*> get <*> get <*> get <*> get <*> get <*> get <*> get
|
|
| 550 | + put (InfoProv x1 x2 x3 x4 x5 x6 x7 x8 x9)
|
|
| 551 | + = put x1 >> put x2 >> put x3 >> put x4 >> put x5 >> put x6 >> put x7 >> put x8 >> put x9
|
|
| 552 | +#elif MIN_VERSION_base(4,20,0)
|
|
| 549 | 553 | get = InfoProv <$> get <*> get <*> get <*> get <*> get <*> get <*> get <*> get
|
| 550 | 554 | put (InfoProv x1 x2 x3 x4 x5 x6 x7 x8)
|
| 551 | 555 | = put x1 >> put x2 >> put x3 >> put x4 >> put x5 >> put x6 >> put x7 >> put x8
|
| ... | ... | @@ -352,6 +352,9 @@ def req_plugins( name, opts ): |
| 352 | 352 | """
|
| 353 | 353 | req_interp(name, opts)
|
| 354 | 354 | |
| 355 | + # Plugins aren't supported with the external interpreter (#14335)
|
|
| 356 | + expect_broken_for(14335,['ext-interp'])(name,opts)
|
|
| 357 | + |
|
| 355 | 358 | if config.cross:
|
| 356 | 359 | opts.skip = True
|
| 357 | 360 |
| 1 | 1 | test('T20696', [extra_files(['A.hs', 'B.hs', 'C.hs'])
|
| 2 | + , expect_broken_for(26552, ['ext-interp'])
|
|
| 2 | 3 | , unless(ghc_dynamic(), skip)], multimod_compile, ['A', ''])
|
| 3 | 4 | test('T20696-static', [extra_files(['A.hs', 'B.hs', 'C.hs'])
|
| 4 | 5 | , when(ghc_dynamic(), skip)], multimod_compile, ['A', '']) |
| ... | ... | @@ -9,12 +9,12 @@ test('fat010', [req_th,extra_files(['THA.hs', 'THB.hs', 'THC.hs']), copy_files], |
| 9 | 9 | # Check linking works when using -fbyte-code-and-object-code
|
| 10 | 10 | test('fat011', [req_th, extra_files(['FatMain.hs', 'FatTH.hs', 'FatQuote.hs'])], multimod_compile, ['FatMain', '-fbyte-code-and-object-code -fprefer-byte-code'])
|
| 11 | 11 | # Check that we use interpreter rather than enable dynamic-too if needed for TH
|
| 12 | -test('fat012', [req_th, unless(ghc_dynamic(), skip), extra_files(['FatTH.hs', 'FatQuote.hs'])], multimod_compile, ['FatTH', '-fprefer-byte-code'])
|
|
| 12 | +test('fat012', [req_th, expect_broken_for(26552, ['ext-interp']), unless(ghc_dynamic(), skip), extra_files(['FatTH.hs', 'FatQuote.hs'])], multimod_compile, ['FatTH', '-fprefer-byte-code'])
|
|
| 13 | 13 | # Check that no objects are generated if using -fno-code and -fprefer-byte-code
|
| 14 | 14 | test('fat013', [req_th, req_bco, extra_files(['FatTH.hs', 'FatQuote.hs'])], multimod_compile, ['FatTH', '-fno-code -fprefer-byte-code'])
|
| 15 | 15 | # When using interpreter should not produce objects
|
| 16 | 16 | test('fat014', [req_th, extra_files(['FatTH.hs', 'FatQuote.hs']), extra_run_opts('-fno-code')], ghci_script, ['fat014.script'])
|
| 17 | -test('fat015', [req_th, unless(ghc_dynamic(), skip), extra_files(['FatQuote.hs', 'FatQuote1.hs', 'FatQuote2.hs', 'FatTH1.hs', 'FatTH2.hs', 'FatTHTop.hs'])], multimod_compile, ['FatTHTop', '-fno-code -fwrite-interface'])
|
|
| 17 | +test('fat015', [req_th, expect_broken_for(26552, ['ext-interp']), unless(ghc_dynamic(), skip), extra_files(['FatQuote.hs', 'FatQuote1.hs', 'FatQuote2.hs', 'FatTH1.hs', 'FatTH2.hs', 'FatTHTop.hs'])], multimod_compile, ['FatTHTop', '-fno-code -fwrite-interface'])
|
|
| 18 | 18 | test('T22807', [req_th, unless(ghc_dynamic(), skip), extra_files(['T22807A.hs', 'T22807B.hs'])]
|
| 19 | 19 | , makefile_test, ['T22807'])
|
| 20 | 20 | test('T22807_ghci', [req_th, unless(ghc_dynamic(), skip), extra_files(['T22807_ghci.hs'])]
|
| ... | ... | @@ -9,7 +9,7 @@ test('SI03', [extra_files(["SI01A.hs"])], multimod_compile_fail, ['SI03', '-v0'] |
| 9 | 9 | test('SI04', [extra_files(["SI01A.hs"])], multimod_compile, ['SI04', '-v0'])
|
| 10 | 10 | test('SI05', [extra_files(["SI01A.hs"])], multimod_compile_fail, ['SI05', '-v0'])
|
| 11 | 11 | test('SI06', [extra_files(["SI01A.hs"])], multimod_compile, ['SI06', '-v0'])
|
| 12 | -test('SI07', [unless(ghc_dynamic(), skip), extra_files(["SI05A.hs"])], multimod_compile, ['SI07', '-fwrite-interface -fno-code'])
|
|
| 12 | +test('SI07', [expect_broken_for(26552, ['ext-interp']), unless(ghc_dynamic(), skip), extra_files(["SI05A.hs"])], multimod_compile, ['SI07', '-fwrite-interface -fno-code'])
|
|
| 13 | 13 | # Instance tests
|
| 14 | 14 | test('SI08', [extra_files(["ClassA.hs", "InstanceA.hs"])], multimod_compile_fail, ['SI08', '-v0'])
|
| 15 | 15 | test('SI09', [extra_files(["ClassA.hs", "InstanceA.hs"])], multimod_compile, ['SI09', '-v0'])
|