Skip to content

Parallelize the Analyzer #4897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 28, 2023
Prev Previous commit
Next Next commit
Make from collection thread-safe
  • Loading branch information
gzm0 committed Aug 23, 2023
commit eb8f45ba1a6461a688f30b2d82bc843ba3ce325c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,8 @@ final class Analyzer(config: CommonPhaseConfig, initial: Boolean,
val nonExistent: Boolean)
extends Analysis.ClassInfo with ClassLoadingState with LoadingResult with ModuleUnit {

var linkedFrom: List[From] = Nil
private[this] val _linkedFrom = new GrowingList[From]
def linkedFrom: List[From] = _linkedFrom.get()

val className = data.className
val kind = data.kind
Expand Down Expand Up @@ -511,7 +512,7 @@ final class Analyzer(config: CommonPhaseConfig, initial: Boolean,
if (nonExistent)
_errors ::= MissingClass(this, from)

linkedFrom ::= from
_linkedFrom ::= from
}

private[this] def validateSuperClass(superClass: Option[ClassInfo]): Option[ClassInfo] = {
Expand Down Expand Up @@ -639,7 +640,8 @@ final class Analyzer(config: CommonPhaseConfig, initial: Boolean,
if (className != ObjectClass)
addStaticDependency(ObjectClass)

var instantiatedFrom: List[From] = Nil
private[this] val _instantiatedFrom = new GrowingList[From]
def instantiatedFrom: List[From] = _instantiatedFrom.get()

val dispatchCalledFrom: mutable.Map[MethodName, List[From]] = mutable.Map.empty

Expand Down Expand Up @@ -1038,7 +1040,7 @@ final class Analyzer(config: CommonPhaseConfig, initial: Boolean,
}

def instantiated()(implicit from: From): Unit = {
instantiatedFrom ::= from
_instantiatedFrom ::= from

/* TODO? When the second line is false, shouldn't this be a linking error
* instead?
Expand Down Expand Up @@ -1097,7 +1099,8 @@ final class Analyzer(config: CommonPhaseConfig, initial: Boolean,
}

private def subclassInstantiated()(implicit from: From): Unit = {
instantiatedFrom ::= from
_instantiatedFrom ::= from

if (!isAnySubclassInstantiated && (isScalaClass || isJSType)) {
isAnySubclassInstantiated = true

Expand Down Expand Up @@ -1264,8 +1267,11 @@ final class Analyzer(config: CommonPhaseConfig, initial: Boolean,
var isAbstractReachable: Boolean = false
var isReachable: Boolean = false

var calledFrom: List[From] = Nil
var instantiatedSubclasses: List[ClassInfo] = Nil
private[this] val _calledFrom = new GrowingList[From]
def calledFrom: List[From] = _calledFrom.get()

private[this] val _instantiatedSubclasses = new GrowingList[ClassInfo]
def instantiatedSubclasses: List[ClassInfo] = _instantiatedSubclasses.get()

def isReflectiveProxy: Boolean =
methodName.isReflectiveProxy
Expand All @@ -1284,7 +1290,7 @@ final class Analyzer(config: CommonPhaseConfig, initial: Boolean,
def reachStatic()(implicit from: From): Unit = {
checkConcrete()

calledFrom ::= from
_calledFrom ::= from
if (!isReachable) {
isAbstractReachable = true
isReachable = true
Expand All @@ -1297,7 +1303,7 @@ final class Analyzer(config: CommonPhaseConfig, initial: Boolean,

if (!isAbstractReachable) {
checkExistent()
calledFrom ::= from
_calledFrom ::= from
isAbstractReachable = true
}
}
Expand All @@ -1312,8 +1318,8 @@ final class Analyzer(config: CommonPhaseConfig, initial: Boolean,

checkConcrete()

calledFrom ::= from
instantiatedSubclasses ::= inClass
_calledFrom ::= from
_instantiatedSubclasses ::= inClass

if (!isReachable) {
isAbstractReachable = true
Expand Down