-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use symbolic names internally #2169
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
Conversation
@@ -571,8 +571,8 @@ class Namer { typer: Typer => | |||
|
|||
/** Create links between companion object and companion class */ | |||
def createLinks(classTree: TypeDef, moduleTree: TypeDef)(implicit ctx: Context) = { | |||
val claz = ctx.effectiveScope.lookup(classTree.name.encode) | |||
val modl = ctx.effectiveScope.lookup(moduleTree.name.encode) | |||
val claz = ctx.denotNamed(classTree.name).symbol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does denotNamed
makes sense here? I changed it to effectiveScope.lookup
in b641181 assuming it was the right thing to do. Doesn't using denotNamed
means that we could find a companion in an outer scope which would be very wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'll revert that change.
7c71b08
to
6868f97
Compare
Status: I went over the whole PR documenting and polishing. Awaiting the backend to be made available so that we can apply the necessary changes to it. |
0dbb1de
to
1a264e1
Compare
EXPANDEDPREFIX Length qualified_NameRef selector_NameRef | ||
TRAITSETTER Length qualified_NameRef selector_NameRef | ||
UNIQUE Length separator_NameRef uniqid_Nat underlying_NameRef? | ||
DEFAULTGETTER Length underlying_NameRef index_Nat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect indentation here and below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation still broken.
1a264e1
to
081a781
Compare
PRs by @smarter are all in and the backend has been moved to https://github.com/lampepfl/scala/. |
081a781
to
ac1415f
Compare
The only remaining test failure is:
I have no idea what that is and can't find the string "ExtractUsedNamesSpecification" anywhere in the repo. @smarter or @felixmulder can you help? |
Some tests contain mangled name ( |
@smarter Thanks! I have tried to change to symbolic names. |
@odersky By the way, the report at the end of the CI output was not helpful here (since this is a regular JUnit test not part of the compiler test framework), but if you search for "ExtractUsedNamesSpecification" in the CI output, you'll find a much more detailed explanation of what failed. |
Seems to all work out now. Ready for review. |
Can you rebase now that #2322 has been merged? |
6005b22
to
49b8df2
Compare
Rebased |
e5f97e3
to
719e7c8
Compare
There's a commit called "Invalide fullName cache when name changes" (7593cf3) that doesn't seem to have anything do with cache invalidation. Did that change appear in another commit, was it lost, or intentionally dropped? |
@@ -244,7 +244,8 @@ class CompilationTests extends ParallelTesting { | |||
}.map(_.checkCompile()).foreach(_.delete()) | |||
} | |||
|
|||
@Test def bytecodeIdempotency: Unit = { | |||
/** Add a `z` so that hey run last. TODO: Only run them selectively? */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: hey -> they
val thisKind = this.info.kind | ||
thisKind == kind || | ||
!thisKind.definesNewName && thisKind.tag > kind.tag && underlying.is(kind) | ||
} | ||
|
||
@sharable // because it's just a cache for performance | ||
private[Names] var myMangledString: String = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be private[this]
apply(original, index) | ||
} | ||
else name | ||
} | ||
} | ||
|
||
/** The kind of names that also encode a variance: 0 for contravariance, 1 for covariance. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1 for contravariance, not 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's 0 now.
EXPANDEDPREFIX Length qualified_NameRef selector_NameRef | ||
TRAITSETTER Length qualified_NameRef selector_NameRef | ||
UNIQUE Length separator_NameRef uniqid_Nat underlying_NameRef? | ||
DEFAULTGETTER Length underlying_NameRef index_Nat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation still broken.
This isn't necessary for this PR to get in, but I think it would be great if we used different types for encoded and decoded names, to make sure we don't use one instead of the other. This should be possible now that we have a clearer picture of when things should be encoded/decoded. |
That was intentionally dropped because it's now redundant. We found a way to do it without changing the name so no invalidation is necessary. |
They take up time and should fail only rarely.
cca78ff
to
c6dafba
Compare
For many kinds this is needed because creation of a name kind involves a side effect, namely registering the name kind. If we delay this we might get a crash on unpickling because a tag is not set yet. This was observed when compiling the collection strawman test.
From http://dotty-ci.epfl.ch/lampepfl/dotty/2165/3:
That's a weird error message, /cc @felixmulder |
My guess is that an assertion fired, but unsure. I'd have to investigate |
The previous change hid the refinements of `info` and apply/unapply. Turning SimpleNameKind and SignedNameKind back into objects fixes that. Neither name kind installs anything as a side effect so turning them into objects is OK.
Some interesting developments. Making all names strict uncovered a bug in |
@@ -61,8 +61,7 @@ object NameKinds { | |||
def infoString: String | |||
} | |||
|
|||
/** The kind of SimpleNames */ | |||
val SimpleNameKind = new NameKind(UTF8) { self => | |||
object SimpleNameKind extends NameKind(UTF8) { self => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ultimately, we should just make the name registration thread-safe, it doesn't cost much and it's much easier to reason about than remembering which NameKinds have side-effects, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is another issue. The problem was not threading but the fact that the registration was not performed at all, since objects are lazy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, indeed that's different. If we had enums we could iterate over the namekinds to register them maybe :).
Change encoding to that symbolic operators are kept internally and are only emitted during the backend. The PR is based on #2128 of which it is the logical conclusion.