Skip to content

Make resolveSuper less slow #2017

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 1 commit into from
Feb 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/MixinOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class MixinOps(cls: ClassSymbol, thisTransform: DenotTransformer)(implicit ctx:
def isCurrent(sym: Symbol) =
ctx.atPhase(thisTransform) { implicit ctx =>
cls.info.member(sym.name).hasAltWith(_.symbol == sym)
// this is a hot spot, where we spend several seconds while compiling stdlib
// unfortunately it will discard and recompute all the member chaches,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: chaches -> caches

// both making itself slow and slowing down anything that runs after it
// because resolveSuper uses hacks with explicit adding to scopes through .enter
// this cannot be fixed by a smarter caching strategy. With current implementation
// we HAVE to discard caches here for correctness
}

/** Does `method` need a forwarder to in class `cls`
Expand All @@ -53,8 +59,8 @@ class MixinOps(cls: ClassSymbol, thisTransform: DenotTransformer)(implicit ctx:
def needsDisambiguation = competingMethods.exists(x=> !(x is Deferred)) // multiple implementations are available
def hasNonInterfaceDefinition = competingMethods.exists(!_.owner.is(Trait)) // there is a definition originating from class
meth.is(Method, butNot = PrivateOrAccessorOrDeferred) &&
isCurrent(meth) &&
(needsDisambiguation || hasNonInterfaceDefinition || meth.owner.is(Scala2x))
(meth.owner.is(Scala2x) || needsDisambiguation || hasNonInterfaceDefinition ) &&
isCurrent(meth)
}

/** Get `sym` of the method that needs a forwarder
Expand Down