@@ -2039,20 +2039,20 @@ abbrev ImportStateM := StateRefT ImportState IO
20392039@[inline] nonrec def ImportStateM.run (x : ImportStateM α) (s : ImportState := default) : IO (α × ImportState) :=
20402040 x.run s
20412041
2042- private def findOLeanParts (mod : Name) : IO (Array System.FilePath ) := do
2042+ private def readModuleDataPartsOfMod (mod : Name) : IO (Array (ModuleData × CompactedRegion) ) := do
20432043 let mFile ← findOLean mod
20442044 unless (← mFile.pathExists) do
20452045 throw <| IO.userError s! "object file '{ mFile} ' of module { mod} does not exist"
2046- let mut fnames := #[mFile]
2046+ let main ← unsafe CompactedRegion.read (α := ModuleData) mFile #[]
2047+ if !main.1 .isModule then
2048+ return #[main]
20472049 -- Opportunistically load all available parts.
20482050 -- Necessary because the import level may be upgraded a later import.
20492051 let sFile := OLeanLevel.server.adjustFileName mFile
2050- if (← sFile.pathExists) then
2051- fnames := fnames.push sFile
2052- let pFile := OLeanLevel.private.adjustFileName mFile
2053- if (← pFile.pathExists) then
2054- fnames := fnames.push pFile
2055- return fnames
2052+ let server ← unsafe CompactedRegion.read (α := ModuleData) sFile #[main.2 ]
2053+ let pFile := OLeanLevel.private.adjustFileName mFile
2054+ let priv ← unsafe CompactedRegion.read (α := ModuleData) pFile #[main.2 , server.2 ]
2055+ return #[main, server, priv]
20562056
20572057partial def importModulesCore
20582058 (imports : Array Import) (globalLevel : OLeanLevel := .private)
@@ -2171,13 +2171,13 @@ where
21712171 moduleNames := s.moduleNames.push i.module
21722172 }
21732173 loadData i := do
2174- let fnames ← if let some arts := arts.find? i.module then
2174+ if let some arts := arts.find? i.module then
21752175 -- Opportunistically load all available parts.
21762176 -- Producer (e.g., Lake) should limit parts to the proper import level.
2177- pure (arts.oleanParts (inServer := globalLevel ≥ .server))
2177+ let fnames := arts.oleanParts (inServer := globalLevel ≥ .server)
2178+ readModuleDataParts fnames
21782179 else
2179- findOLeanParts i.module
2180- readModuleDataParts fnames
2180+ readModuleDataPartsOfMod i.module
21812181 loadIR? i := do
21822182 let irFile? ← if let some arts := arts.find? i.module then
21832183 pure arts.ir?
0 commit comments