Skip to content
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

Fix GADT-related memory leak #3233

Merged
merged 5 commits into from
Oct 4, 2017
Merged

Fix GADT-related memory leak #3233

merged 5 commits into from
Oct 4, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Oct 3, 2017

There was a confusion which led to the wrong gadt map being used
for pattern-bound variables if there was no other GADT variable
in the enclosing method.

This led to the outermost gadt map in the initial context being
populated with type bounds which never went away.

@odersky
Copy link
Contributor Author

odersky commented Oct 3, 2017

test performance please

@dottybot
Copy link
Member

dottybot commented Oct 3, 2017

performance test scheduled: 1 job(s) in queue, 0 running.

@dottybot
Copy link
Member

dottybot commented Oct 3, 2017

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/3233/ to see the changes.

Benchmarks is based on merging with master (96b0ae4)

@@ -532,7 +532,7 @@ object Contexts {
moreProperties = Map.empty
typeComparer = new TypeComparer(this)
searchHistory = new SearchHistory(0, Map())
gadt = new GADTMap(SimpleMap.Empty)
gadt = new GADTMap(SimpleMap.Empty) // EmptyGADTMap
Copy link
Member

Choose a reason for hiding this comment

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

Was this supposed to be = EmptyGADTMap ?

@@ -289,6 +281,8 @@ class PostTyper extends MacroTransform with SymTransformer { thisTransformer =>
case _ =>
}
super.transform(tree)
case Typed(Ident(nme.WILDCARD), _) =>
tree // skip checking pattern type
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because type bounds in a pattern need not conform to selector bounds. I.e. you have

type Tree[T >: Null <: Type]

You are still allowed to write

case x: Tree[_]

(which translates to)

case x: (_: Tree[_])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am going to refine & explain the logic better

@@ -256,7 +256,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTrans
case tree @ Annotated(annotated, annot) =>
cpy.Annotated(tree)(transform(annotated), transformAnnot(annot))
case tree: AppliedTypeTree =>
Checking.checkAppliedType(tree)
Checking.checkAppliedType(tree, boundsCheck = !ctx.mode.is(Mode.Pattern))
Copy link
Member

Choose a reason for hiding this comment

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

Now I'm confusing about why we would write this instead of if (!ctx.mode.is(Mode.Pattern)) Checking.checkAppliedType(tree) :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because checkAppliedType also does other things besides bounds checking.

There was a confusion which led to the wrong gadt map being used
for pattern-bound variables if there was no other GADT variable
in the enclosing method.

This led to the outermost gadt map in the initial context being
populated with type bounds which never went away.
If -Xprompt is set, pause a dotty.tools.dotc.Bench task between compiler
runs. This is useful for, e.g. taking a memory snapshot at a predictable time.
@smarter smarter merged commit 443bdb1 into scala:master Oct 4, 2017
@allanrenucci allanrenucci deleted the fix-gadts branch December 14, 2017 19:20
smarter added a commit to dotty-staging/dotty that referenced this pull request Feb 12, 2018
We no longer convert GADT bounds into normal bounds since scala#3233 was
merged.
smarter added a commit to dotty-staging/dotty that referenced this pull request Feb 12, 2018
We no longer convert GADT bounds into normal bounds since scala#3233 was
merged.
smarter added a commit to dotty-staging/dotty that referenced this pull request Feb 13, 2018
We no longer convert GADT bounds into normal bounds since scala#3233 was
merged.
smarter added a commit to dotty-staging/dotty that referenced this pull request Feb 14, 2018
We no longer convert GADT bounds into normal bounds since scala#3233 was
merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants