@@ -472,7 +472,7 @@ rawDependencyInformation fs = do
472
472
reportImportCyclesRule :: Recorder (WithPriority Log ) -> Rules ()
473
473
reportImportCyclesRule recorder =
474
474
defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \ ReportImportCycles file -> fmap (\ errs -> if null errs then (Just " 1" ,([] , Just () )) else (Nothing , (errs, Nothing ))) $ do
475
- DependencyInformation {.. } <- useNoFile_ GetModuleGraph
475
+ DependencyInformation {.. } <- useWithSeparateFingerprintRule_ GetModuleGraphTransDepsFingerprints GetModuleGraph file
476
476
case pathToId depPathIdMap file of
477
477
-- The header of the file does not parse, so it can't be part of any import cycles.
478
478
Nothing -> pure []
@@ -608,7 +608,7 @@ typeCheckRule recorder = define (cmapWithPrio LogShake recorder) $ \TypeCheck fi
608
608
-- very expensive.
609
609
when (foi == NotFOI ) $
610
610
logWith recorder Logger. Warning $ LogTypecheckedFOI file
611
- typeCheckRuleDefinition hsc pm
611
+ typeCheckRuleDefinition hsc pm file
612
612
613
613
knownFilesRule :: Recorder (WithPriority Log ) -> Rules ()
614
614
knownFilesRule recorder = defineEarlyCutOffNoFile (cmapWithPrio LogShake recorder) $ \ GetKnownTargets -> do
@@ -643,7 +643,10 @@ dependencyInfoForFiles fs = do
643
643
go (Just ms) _ = Just $ ModuleNode [] ms
644
644
go _ _ = Nothing
645
645
mg = mkModuleGraph mns
646
- pure (fingerprintToBS $ Util. fingerprintFingerprints $ map (maybe fingerprint0 msrFingerprint) msrs, processDependencyInformation rawDepInfo bm mg)
646
+ let shallowFingers = IntMap. fromList $ foldr' (\ (i, m) acc -> case m of
647
+ Just x -> (getFilePathId i,msrFingerprint x): acc
648
+ Nothing -> acc) [] $ zip _all_ids msrs
649
+ pure (fingerprintToBS $ Util. fingerprintFingerprints $ map (maybe fingerprint0 msrFingerprint) msrs, processDependencyInformation rawDepInfo bm mg shallowFingers)
647
650
648
651
-- This is factored out so it can be directly called from the GetModIface
649
652
-- rule. Directly calling this rule means that on the initial load we can
@@ -652,14 +655,15 @@ dependencyInfoForFiles fs = do
652
655
typeCheckRuleDefinition
653
656
:: HscEnv
654
657
-> ParsedModule
658
+ -> NormalizedFilePath
655
659
-> Action (IdeResult TcModuleResult )
656
- typeCheckRuleDefinition hsc pm = do
660
+ typeCheckRuleDefinition hsc pm fp = do
657
661
IdeOptions { optDefer = defer } <- getIdeOptions
658
662
659
663
unlift <- askUnliftIO
660
664
let dets = TypecheckHelpers
661
665
{ getLinkables = unliftIO unlift . uses_ GetLinkable
662
- , getModuleGraph = unliftIO unlift $ useNoFile_ GetModuleGraph
666
+ , getModuleGraph = unliftIO unlift $ useWithSeparateFingerprintRule_ GetModuleGraphTransDepsFingerprints GetModuleGraph fp
663
667
}
664
668
addUsageDependencies $ liftIO $
665
669
typecheckModule defer hsc dets pm
@@ -756,9 +760,10 @@ ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
756
760
depSessions <- map hscEnv <$> uses_ (GhcSessionDeps_ fullModSummary) deps
757
761
ifaces <- uses_ GetModIface deps
758
762
let inLoadOrder = map (\ HiFileResult {.. } -> HomeModInfo hirModIface hirModDetails emptyHomeModInfoLinkable) ifaces
763
+ de <- useWithSeparateFingerprintRule_ GetModuleGraphTransDepsFingerprints GetModuleGraph file
759
764
mg <- do
760
765
if fullModuleGraph
761
- then depModuleGraph <$> useNoFile_ GetModuleGraph
766
+ then return $ depModuleGraph de
762
767
else do
763
768
let mgs = map hsc_mod_graph depSessions
764
769
-- On GHC 9.4+, the module graph contains not only ModSummary's but each `ModuleNode` in the graph
@@ -771,7 +776,6 @@ ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
771
776
nubOrdOn mkNodeKey (ModuleNode final_deps ms : concatMap mgModSummaries' mgs)
772
777
liftIO $ evaluate $ liftRnf rwhnf module_graph_nodes
773
778
return $ mkModuleGraph module_graph_nodes
774
- de <- useNoFile_ GetModuleGraph
775
779
session' <- liftIO $ mergeEnvs hsc mg de ms inLoadOrder depSessions
776
780
777
781
-- Here we avoid a call to to `newHscEnvEqWithImportPaths`, which creates a new
@@ -801,7 +805,7 @@ getModIfaceFromDiskRule recorder = defineEarlyCutoff (cmapWithPrio LogShake reco
801
805
, old_value = m_old
802
806
, get_file_version = use GetModificationTime_ {missingFileDiagnostics = False }
803
807
, get_linkable_hashes = \ fs -> map (snd . fromJust . hirCoreFp) <$> uses_ GetModIface fs
804
- , get_module_graph = useNoFile_ GetModuleGraph
808
+ , get_module_graph = useWithSeparateFingerprintRule_ GetModuleGraphTransDepsFingerprints GetModuleGraph f
805
809
, regenerate = regenerateHiFile session f ms
806
810
}
807
811
hsc_env' <- setFileCacheHook (hscEnv session)
@@ -977,7 +981,7 @@ regenerateHiFile sess f ms compNeeded = do
977
981
Just pm -> do
978
982
-- Invoke typechecking directly to update it without incurring a dependency
979
983
-- on the parsed module and the typecheck rules
980
- (diags', mtmr) <- typeCheckRuleDefinition hsc pm
984
+ (diags', mtmr) <- typeCheckRuleDefinition hsc pm f
981
985
case mtmr of
982
986
Nothing -> pure (diags', Nothing )
983
987
Just tmr -> do
@@ -1135,7 +1139,7 @@ needsCompilationRule file
1135
1139
| " boot" `isSuffixOf` fromNormalizedFilePath file =
1136
1140
pure (Just $ encodeLinkableType Nothing , Just Nothing )
1137
1141
needsCompilationRule file = do
1138
- graph <- useNoFile GetModuleGraph
1142
+ graph <- useWithSeparateFingerprintRule GetModuleGraphImmediateReverseDepsFingerprints GetModuleGraph file
1139
1143
res <- case graph of
1140
1144
-- Treat as False if some reverse dependency header fails to parse
1141
1145
Nothing -> pure Nothing
@@ -1247,6 +1251,19 @@ mainRule recorder RulesConfig{..} = do
1247
1251
persistentDocMapRule
1248
1252
persistentImportMapRule
1249
1253
getLinkableRule recorder
1254
+ defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \ GetModuleGraphTransDepsFingerprints file -> do
1255
+ di <- useNoFile_ GetModuleGraph
1256
+ let finger = lookupFingerprint file di (depTransDepsFingerprints di)
1257
+ return (fingerprintToBS <$> finger, ([] , finger))
1258
+ defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \ GetModuleGraphTransReverseDepsFingerprints file -> do
1259
+ di <- useNoFile_ GetModuleGraph
1260
+ let finger = lookupFingerprint file di (depTransReverseDepsFingerprints di)
1261
+ return (fingerprintToBS <$> finger, ([] , finger))
1262
+ defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \ GetModuleGraphImmediateReverseDepsFingerprints file -> do
1263
+ di <- useNoFile_ GetModuleGraph
1264
+ let finger = lookupFingerprint file di (depImmediateReverseDepsFingerprints di)
1265
+ return (fingerprintToBS <$> finger, ([] , finger))
1266
+
1250
1267
1251
1268
-- | Get HieFile for haskell file on NormalizedFilePath
1252
1269
getHieFile :: NormalizedFilePath -> Action (Maybe HieFile )
0 commit comments