-
Notifications
You must be signed in to change notification settings - Fork 1
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
Outline Typing #44
Outline Typing #44
Conversation
The old approach of using the first, last, and middle characters only lays a trap for generate names that have little or no entropy at these locations. For instance, fresh existential names generated in "as seen from" operations are one such case, and when compiling large batches of files the name table can become imbalanced. This seems to be the bottleneck compiling the enourmous (generated) test suite for ScalaTest itself: scala/scala-dev#246 (comment) This commit uses all characters to compute the hashCode. It improves the compilation time of ScalaTest tests from 487s to 349s (0.71x). It would still be useful to avoid generating these fresh names with a global counter, as this represents a steady name leak in long-lived Globals (e.g. the presentation compiler.)
Fallback to the old style when the more than 64 varargs are provided. Backport of a limit introduced in 2.13.x in scala#7678
I think protected accessors are generate pre-pickler in Scala 2 (in Dotty they aren't, but I'm not 100% sure that handles all cases correctly), so that probably leads to the same issue we have with super accessors. Regarding performance, in scala/scala3#4767 I observed that the lock in https://github.com/lampepfl/dotty/blob/29aeb02be0c08a20373027a0d80deaa87cb699ff/compiler/src/dotty/tools/dotc/classpath/ZipAndJarFileLookupFactory.scala#L181 (which corresponds to https://github.com/scala/scala/blob/bec2441a24cbf3159a1118049b857a5ae7c452eb/src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala#L253 in scala/scala) seemed to be a bottleneck, but I haven't had time to experiment with alternative approaches like having an option to make the cache per compiler instance. |
@smarter AFAICT protected accessors are only called from elsewhere in the same compilation unit which wouldn't be a problem. We should follow dotty's lead in Scala 2.14. and move generation post-pickler IMO. I've never really looked at this area before. Some aspects look wrong. We don't emit scala So that leaves class JavaInteraction extends java.io.CharArrayReader {
<artifact> def protected$count(x$1: p.b.JavaInteraction): Int = x$1.count;
<artifact> def protected$setcount(x$1: p.b.JavaInteraction, x$2: Int): Unit = x$1.count = x$2;
<paramaccessor> private[this] val arr: Array[Char] = _;
def <init>(arr: Array[Char]): p.b.JavaInteraction = {
JavaInteraction.super.<init>(arr);
()
};
class Inner extends scala.AnyRef {
def <init>(): JavaInteraction.this.Inner = {
Inner.super.<init>();
()
};
def m: Unit = {
scala.Console.println("count before: ".+(JavaInteraction.this.protected$count(JavaInteraction.this)));
JavaInteraction.this.protected$setcount(JavaInteraction.this, JavaInteraction.this.protected$count(JavaInteraction.this).+(1));
scala.Console.println("count after: ".+(JavaInteraction.this.protected$count(JavaInteraction.this)))
}
}
}; It seems to me like For bonus points we would emit it as a static method like Java's |
to trigger XSS vuln, simply paste this into the search bar: ``` "\><img/src='1'onerror=alert(777111)>{{7*7}} ``` all credit for finding the vulnerability goes to *Yeasir Arafat* <skylinearafat@gmail.com>
Call TypeName.toTermName less frequently.
rather than escaping the search string, which breaks the search for e.g. `:+` solution contributed by NthPortal in scala#8018 (comment)
fix XSS vulnerability in scaladoc search by escaping the input parameter
correct jansi version in intellij setup
Limit string interpolation intrinsic to avoid compiler SOE
Cancel in-progress timer task on a cache hit. This avoids reducing the effective deferred close delay when the old timer task fires and sees a ref count of zero, even though the ref count has since been positive.
Optimize importedSymbol
Improve hash code of Names
1781a17
to
ae097be
Compare
Due to alignment, TermName_R (which doesn't cache the provided string for toString) takes up just as much space as TermName_S. The code ends up somewhat easier to read with by just encoding the difference with the a nullable field.
…leanup Cleanups around caching of classpath/classloaders
``` scala> :power Power mode enabled. :phase is at typer. import scala.tools.nsc._, intp.global._, definitions._ Try :help or completions for vals._ and power._ scala> val t = TermName("abcdefghijklmnopqrstuvwxyz") t: $r.intp.global.TermName = abcdefghijklmnopqrstuvwxyz scala> t.subName(0, 25) res0: $r.intp.global.TermName = abcdefghijklmnopqrstuvwxy scala> res0.start res1: Int = 474232 scala> t.start res2: Int = 474232 ```
Fix regression in import name comparison
Rationalize subclasses of Name
287c3b2
to
9e3e44d
Compare
Fix scalap parsing/printing of enum and class constant types
9e3e44d
to
c74a9b1
Compare
Demo: ``` $ cat sandbox/test.scala && (scalac-ref 2.12.x -Ytyper-debug sandbox/test.scala 2>&1) > /tmp/old.log && (qscalac -Ytyper-debug sandbox/test.scala 2>&1) > /tmp/new.log && diff -U1000 /tmp/{old,new}.log ``` ```scala trait C { type X def foo: X } ``` ```diff --- /tmp/old.log 2019-05-20 13:56:45.000000000 +1000 +++ /tmp/new.log 2019-05-20 13:56:47.000000000 +1000 @@ -1,12 +1,10 @@ |-- <empty> EXPRmode-POLYmode-QUALmode (site: package <root>) +|-- <empty> EXPRmode-POLYmode-QUALmode (site: package <root>) | \-> <empty>.type |-- class C BYVALmode-EXPRmode (site: package <empty>) | |-- X BYVALmode-EXPRmode (site: trait C) | | \-> [type X] C.this.X | |-- def foo BYVALmode-EXPRmode (site: trait C) | | |-- X TYPEmode (site: method foo in C) | | | \-> C.this.X -| | |-- X TYPEmode (site: method foo in C) -| | | \-> C.this.X | | \-> [def foo] => C.this.X | \-> [trait C] C ```
Avoid typechecking val and def tpt-s twice
1c1aabf
to
4c41101
Compare
- Allow user specified reporter - funnel javac errors through it - funnel PipelineMain's logging through it, too. - Use a separate FileManager for each javac invocation to avoid an apparent race condition. - Expose config knobs programatically rather than only through system properties.
4c41101
to
c9d68d8
Compare
In this new mode, the RHS of definitions is only typechecked if the definition lacks an explicit type ascription, or or it may contain a super call that is compiled to a trait super accessor. Refer to the new test case for a motivating example.
c9d68d8
to
3cfb31c
Compare
A new mode for
PipelineMain
that can shorten the critical path of a build and extract more parallelism from the post-typer compiler phases (at the cost of instantiating multiple instances ofGlobal
).First, we compile all sources with
-Youtline -Ystop-after:pickler
. The first option disables typechecking of the RHS of definitions that have ascribed types.The RHS is not skipped when it contains a
super
call that might need a super accessor. (hat tip to @smarter for finding this corner case in dotty). Are there more like it that we haven't identified?The pickles are then exported and made available to downstream compilation, as is also the case with the
strategy=Pipeline
. The sources for the current projects are then compiled in parallel in chunks, also using the exported pickles on the classpath.Optionally, we can share the name table between
Global
instances to reduce the memory and bookkeeping overhead of the traditional approach of having this inside the cake. For backwards binary compatibility reasons, this is implemented with an abundance of casts and other hacks.Testing this out
guardian-frontend
. In the past I've experimented with the full multi-module build, but in this case I want to focus on thecommon
project that all other depend on and that is the bottleneck for a full clean build.Pipeline + Outline
Pipeline
Traditional
Summary
Caveats
-Ymacro-classpath
setting is needed with the macro implementation.