-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Check flags that are not supposed to be mutated by completion #7427
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
Check flags that are not supposed to be mutated by completion #7427
Conversation
There's some flags for which this isn't true currently: #4221 |
12be72d
to
56e8dfc
Compare
Test performance please |
44021ea
to
d8a51f2
Compare
On top #7449. |
Test performance please |
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Was that the title case letter or am I not in the whitelist? AFAIK I was added to the bot's whitelist at some point... |
Yes, it seems to be case-sensitive, we should improve: https://github.com/lampepfl/bench/blob/master/bin/process#L45 |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/7427/ to see the changes. Benchmarks is based on merging with master (b28ce64) |
f7c1bb0
to
aebd4c5
Compare
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/7427/ to see the changes. Benchmarks is based on merging with master (1d5e6ed) |
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.
Spending a flag on an internal check is too wasteful, I think. Also, the code used in hotspots is too expensive.
I believe this suffers from too early generalization. It seems to the problem is only with Deferred, right? What exactly is the problem? Is there a cheaper way to solve it, without creating an expensive general scaffolding?
@@ -160,20 +160,34 @@ object SymDenotations { | |||
*/ | |||
private[dotc] final def flagsUNSAFE: FlagSet = myFlags | |||
|
|||
private def setMyFlags(flags: FlagSet) = | |||
lazy val immutableFlags = if myInfo.isInstanceOf[SymbolLoader] then AfterLoadFlags else FromStartFlags |
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.
Every local lazy val is a boxed object, should be avoided in performance sensitive code like this.
True, only 2 flags left. How bad will the performance impact be if we add another
I assumed this would help performance – however, it seems it only positively impacted the performance of
This is because we have the
So there are three different states to track here which requires two bits. The following chunks of code are considered as symbol loading (between
Is there anything else apart from the lazy vals that box and the
The problem with the So this line queries the flags of some class member So At the same time, at that particular place we can be absolutely sure Hence the solution of the conditionally immutable flags.
We can just hard-code the |
Can we set Deferred for opaque types from the start? If not, then the next best choice is to hardcode Deferred in isCurrent.
I believe so. A reasonable way to track this is to count how many object allocations are executed by the code (lambdas count). For hot code the goal is 0.
Why do we need this? |
I believe because we are creating a symbol from scratch, so we should be able to modify anything at all about it. |
8d256c1
to
326696f
Compare
test performance please |
performance test scheduled: 2 job(s) in queue, 1 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/7427/ to see the changes. Benchmarks is based on merging with master (9193c44) |
…types Also fix a neg test for i3067. After this modification to the completion algorithm, implicit definitions without explicit types stay visible in the implicit scope and hence, the error of the missing implicit is not reporter. This is fine, however, since the real error to be fixed is the lack of an explicit type of the implicit value, not the lack of the implicit value itself.
This flag is set on symbol completion based on other semantic info. Fix i7407 test error message FTTB it is a cyclic error. It requests the user to fully specify the type of the method. Once they do so, an intended "implicit not found" message appears. Displaying the correct message directly requires adding `Macro` flag to `FromStartFlags`, which is not correct. Until we find a workaround, this solution is a reasonable trade-off because it offers an unambiguous action (to fully specify the type of the method) for the user to take to see the correct error message. The reason the cyclic error appears in first place is as follows. Given `inline def g = qc`, we typecheck `qc`. However, `qc` requires an implicit QuoteContext which can only be synthetically generated for the bodies of macros. Hence we need to see if `g` is a macro, and to do so, we need to complete it. To complete it, we need to typecheck its body, which yields the cyclic error.
Scala2x is a flag set for all the Scala 2 compliled classes. The information on what Scala version was used to compile the class file is available from the bytes of the classfile itself. Hence we cannot have this information from start, it will only be available on load. See ClassfileParser.unpickleOrParseInnerClasses for details on how the Scala version is determined.
This flag can be unpickled e.g. by Scala2Unpickler.readDisambiguatedSymbol. Hence it is not known from start.
`moduleRoot` is derived from moduleClassRoot which is being loaded. Since it is derived during the loading sequence of `moduleClassRoot`, we can argue that `moduleRoot` is loaded during this sequence as well. Hence we mark `moduleRoot` as loading by setting its completer to a temporary value. We set the completer back after the loading is done.
It must be set for derived value classes on completion.
Make sure that we complete denotations only in case we absolutely must to when evaluating predicates on flags.
326696f
to
d7a049b
Compare
No description provided.