Skip to content

Commit

Permalink
When recovering from deserialization IOException, don't useCaches whe…
Browse files Browse the repository at this point in the history
…n ensureParsed again
  • Loading branch information
JaroslavTulach committed Feb 6, 2024
1 parent c729c74 commit 947824e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ class Compiler(
*/
def generateDocs(module: Module): Module = {
initialize()
parseModule(module, isGenDocs = true)
parseModule(
module,
irCachingEnabled && !context.isInteractive(module),
isGenDocs = true
)
module
}

Expand Down Expand Up @@ -244,7 +248,7 @@ class Compiler(
initialize()
modules.foreach(m =>
try {
parseModule(m)
parseModule(m, irCachingEnabled && !context.isInteractive(m))
} catch {
case e: Throwable =>
context.log(
Expand Down Expand Up @@ -286,12 +290,12 @@ class Compiler(
)
)
context.updateModule(module, _.invalidateCache())
parseModule(module)
parseModule(module, irCachingEnabled && !context.isInteractive(module))
importedModules
.filter(isLoadedFromSource)
.map(m => {
if (m.getBindingsMap() == null) {
parseModule(m)
parseModule(m, irCachingEnabled && !context.isInteractive(module))
}
})
runImportsAndExportsResolution(module, generateCode)
Expand All @@ -302,7 +306,7 @@ class Compiler(

if (irCachingEnabled) {
requiredModules.foreach { module =>
ensureParsed(module)
ensureParsed(module, !context.isInteractive(module))
}
}
requiredModules.foreach { module =>
Expand Down Expand Up @@ -482,7 +486,7 @@ class Compiler(

private def ensureParsedAndAnalyzed(module: Module): Unit = {
if (module.getBindingsMap() == null) {
ensureParsed(module)
ensureParsed(module, irCachingEnabled && !context.isInteractive(module))
}
if (context.isSynthetic(module)) {
// Synthetic modules need to be import-analyzed
Expand Down Expand Up @@ -512,7 +516,7 @@ class Compiler(
* @param module - the scope from which docs are generated.
*/
def gatherImportStatements(module: Module): Array[String] = {
ensureParsed(module)
ensureParsed(module, irCachingEnabled && !context.isInteractive(module))
val importedModules = context.getIr(module).imports.flatMap {
case imp: Import.Module =>
imp.name.parts.take(2).map(_.name) match {
Expand All @@ -535,6 +539,7 @@ class Compiler(

private def parseModule(
module: Module,
useCaches: Boolean,
isGenDocs: Boolean = false
): Unit = {
context.log(
Expand All @@ -544,7 +549,7 @@ class Compiler(
)
context.updateModule(module, _.resetScope())

if (irCachingEnabled && !context.isInteractive(module)) {
if (useCaches) {
if (context.deserializeModule(this, module)) {
return
}
Expand Down Expand Up @@ -638,14 +643,19 @@ class Compiler(
* @param module the module to ensure is parsed.
*/
def ensureParsed(module: Module): Unit = {
val useCaches = irCachingEnabled && !context.isInteractive(module)
ensureParsed(module, useCaches)
}

def ensureParsed(module: Module, useCaches: Boolean): Unit = {
if (
!context
.getCompilationStage(module)
.isAtLeast(
CompilationStage.AFTER_PARSING
)
) {
parseModule(module)
parseModule(module, useCaches)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ImportResolver(compiler: Compiler) {
u.invalidateCache()
}
)
compiler.ensureParsed(current)
compiler.ensureParsed(current, false)
return analyzeModule(current)
}
// put the list of resolved imports in the module metadata
Expand Down

0 comments on commit 947824e

Please sign in to comment.