summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Run DCE before the closure optimizer (fixes a crash)Lukas Rytz2016-01-201-0/+19
| | | | | | | | | | | | | | | Before identifying function callsites within the same method as a closure allocation, run DCE. The ProdCons analysis used to identify these function calls may crash if there is unreachable code, as observed in the community build with scala-js. The crash was rare because inlining, which is performed before closure optimizations, already runs DCE. However, inlining may render more code unreachable (e.g. when inlining a method that throws). Also make sure that DCE is always performed on the callee before inlining: move the DCE invocation into the inlineCallsite method, which is also invoked by the closure optimizer.
* Apply local optimization based on nullness informationLukas Rytz2015-12-153-14/+68
| | | | | | | | | Optimize IFNULL branches to GOTO when (non-)nullness of the tested value is known statically. This enables unreachable code to be removed, which in turn enables boxes to be eliminated. Changed a test flag from `-Ynooptimise` to `-Yopt:l:classpath` - I still have to do this systematically, this will follow later.
* Eliminate unnecessary castsLukas Rytz2015-12-153-10/+41
| | | | | | Eliminate casts that are statically known to succeed. This enables boxes to be eliminated and simplifies the implementation of closure allocation elimination.
* Eliminate non-escaping boxes, tuples and refsLukas Rytz2015-12-152-55/+332
| | | | | | | | | Eliminate boxes, tuples and refs that are created and used within a single method without escaping. For details on the implementation see the doc comment in class BoxUnbox. This commit also cleans up the logic of inter-dependent method-level optimizations that run until reaching a fixpoint.
* Make some testing tools from InlinerTest available to other testsLukas Rytz2015-12-133-20/+17
|
* Rename test MethodLevelOpts -> MethodLevelOptsTestLukas Rytz2015-12-131-4/+4
|
* Support specialized functions in closure optimizerLukas Rytz2015-11-132-0/+207
| | | | | | | | | | Fixes https://github.com/scala/scala-dev/issues/52. An IndyLambda may create a specialized function type, where the SAM is the corresponding specialized variant of apply. If this closure is invoked through the generic apply method, the closure optimizer would previously not re-write the invocation to the $anonfun method. This is now done, including the necessary box / unbox operations.
* Fix specialized function class names in closure optimizerLukas Rytz2015-11-101-0/+17
|
* Copy propagation, remove unused values (closures!) and local variablesLukas Rytz2015-11-103-27/+184
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Copy propagation uses an AliasingAnalyzer: it replaces a `LOAD n` instruction by `LOAD m` where m is the smallest alias of n. This leads to stale STORE instructions. Stale STOREs are identified using a ProdCons analyzer and replaced by POPs. Values that are pushed on the stack by a side-effect free instruction and consumed by a POP are then removed by `eliminatePushPop`. This includes elimination of unused closure allocations and unused boxes and tuple allocations (*). A final cleanup eliminates `STORE x; LOADx` pairs where the stored value is not otherwise used. Fixes - https://github.com/scala/scala-dev/issues/25 - https://github.com/scala/scala-dev/issues/7 - https://github.com/scala/scala-dev/issues/14 - https://github.com/scala/scala-dev/issues/12 (*) We don't yet rewrite reads of boxes and tuples yet. For example, `val x = (1, 2); x._1` remains a method invocation and the tuple cannot be eliminated (https://github.com/scala/scala-dev/issues/11). Inspired in many ways by Miguel's work!
* Track aliases of primitive values in AliasingFrameLukas Rytz2015-10-292-1/+64
| | | | | This allows using an AliasingAnalyzer for copy propagation (subsequent commit).
* Merge pull request #4808 from retronym/ticket/9527Seth Tisue2015-10-274-0/+28
|\ | | | | SI-9527 Fix NPE in ambiguous implicit error generation
| * SI-9527 Fix NPE in ambiguous implicit error generationJason Zaugg2015-10-214-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In #4673, an annotation was added to allow customization of the compiler error for ambigous implicits. This change had incorrect assumptions about the shape of trees that would be generated during implicit search, and failed to account for the results of eta expanded methods when searching for a function type. This commit: - Uses the symbol from `ImpilcitInfo`, rather than calling `Tree#symbol` which is fraught with the danger of returning a null symbol for something other than an application. - Adds a test for customized messages for a polymorphic, eta expanded method, and generalizes `treeTypeArgs` to handle the implicit tree of shape `{ (x: X) => f[A](x)}`.
* | Merge pull request #4794 from densh/topic/predef-autoboxingSeth Tisue2015-10-271-0/+35
|\ \ | | | | | | Fixes an inconsistency between BoxesRunTime and Predef's autoboxing
| * | Fixes an inconsistency between BoxesRunTime and Predef's autoboxingDenys Shabalin2015-10-081-0/+35
| |/ | | | | | | | | | | | | | | | | | | | | | | Previously autoboxing implicits in Predef were inconsistent with BoxesRunTime box/unbox due to different treatment of unboxing of nulls. Implicits didn't check for null and would crash with NPE unlike the BoxesRunTime which correctly returned zero value of given type. The fix is trivial: lets just use asInstanceOfs to implement implicits in Predef. This would ensure that both have the same behaviour and that the two would not diverge again in the future.
* | Merge pull request #4820 from lrytz/t9535Lukas Rytz2015-10-273-0/+36
|\ \ | | | | | | SI-9535 correct bytecode and generic signatures for @throws[TypeParam]
| * | SI-9535 correct bytecode and generic signatures for @throws[TypeParam]Lukas Rytz2015-10-263-0/+36
| | | | | | | | | | | | | | | | | | | | | For @throws[E] where E is not a class type, GenASM incorrectly writes the non-class type to the classfile. GenBCode used to crash before this commit. Now GenBCode correctly emits the erased type (like javac) and adds a generic signature.
* | | Merge pull request #4815 from som-snytt/test/stringcontext-fJason Zaugg2015-10-273-193/+160
|\ \ \ | | | | | | | | f interp test is junit
| * | | f interp test is junitSom Snytt2015-10-253-193/+160
| |/ / | | | | | | | | | | | | | | | | | | Moves test/files/run/stringinterpolation_macro-run.scala to the junit test class test/junit/scala/StringContextTest.scala. Adds a couple of assertions to the test.
* | | Merge pull request #4807 from lrytz/opt/innerClassAttrLukas Rytz2015-10-262-4/+4
|\ \ \ | |/ / |/| | Simplify and correctify calculation of the InnerClass attribute
| * | Simplify and correctify calculation of the InnerClass attributeLukas Rytz2015-10-202-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The InnerClass attribute needs to contain an entry for every nested class that is defined or referenced in a class. Details are in a doc comment in BTypes.scala. Instead of collecting ClassBTypes of nested classes into a hash map during code generation, traverse the class before writing it out to disk. The previous approach was incorrect as soon as the generated bytecode was modified by the optimzier (DCE, inlining). Fixes https://github.com/scala/scala-dev/issues/21.
* | | Merge pull request #4802 from SethTisue/merge-2.11-to-2.12-oct-16Lukas Rytz2015-10-213-0/+88
|\ \ \ | |/ / |/| | merge 2.11 to 2.12 Oct 16
| * | merge 2.11.x onto 2.12.x, Oct 16 2015Seth Tisue2015-10-163-0/+88
| |\ \ | | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | there were merge conflicts in the Eclipse config that I resolved with --ours. I invite @performantdata to submit a followup PR bringing the Eclipse stuff into a good state on 2.12.x. there was a test failure in test/junit/scala/collection/mutable/OpenHashMapTest.scala due to the 2.12 compiler emitting the field backing a private var differently (with an unmangled name). Lukas says the difference is expected, so I just updated the code in the test. there were no other merge conflicts. % git log --decorate --oneline -1 origin/2.11.x | cat ae5f0de (origin/HEAD, origin/2.11.x) Merge pull request #4791 from performantdata/issue/9508 % git log --decorate --oneline -1 origin/2.12.x | cat c99e53e (HEAD -> 2.12.x, origin/2.12.x) Merge pull request #4797 from lrytz/M3-versions % export MB=$(git merge-base 2.12.x origin/2.11.x) % echo $MB 42cafa21f3c4a08c6dd34608278f810b6ec2886f % git log --graph --oneline --decorate $MB...origin/2.11.x | cat * ae5f0de (origin/HEAD, origin/2.11.x) Merge pull request #4791 from performantdata/issue/9508 |\ | * 08dca37 (origin/pull/4791) SI-9508 fix classpaths in Eclipse configuration * | fe76232 Merge pull request #4798 from performantdata/issue/9513 |\ \ | * | 9c97a7f (origin/pull/4798) Suppress unneeded import. | * | 30d704d Document some OpenHashMap internal methods. | * | 1fb32fc SI-9513 decrement "deleted" count in OpenHashMap.put() when slot reused | |/ * | 14f875c Merge pull request #4788 from dk14/patch-1 |\ \ | * | 42acd55 (origin/pull/4788) explicitly specify insertion-order feature in docs | / * | 68ce049 Merge pull request #4771 from som-snytt/issue/9492-here |\ \ | * | f290962 (origin/pull/4771) SI-9492 Line trimming paste | * | bc3589d SI-9492 REPL paste here doc | / * | 9834fc8 Merge pull request #4610 from todesking/spec-implicits-remove-obsolete |\ \ | * | 46009b1 (origin/pull/4610) Add view/context-bound parameter ordering rule | * | 6eba305 Spec: Implicit parameters with context/view bound is allowed since 2.10 | / * | d792e35 Merge pull request #4789 from janekdb/2.11.x-param-names-predicates-operations |\ \ | |/ |/| | * b19a07e (origin/pull/4789) Rename forall, exists and find predicate and operator params. |/ * 648c7a1 Merge pull request #4790 from SethTisue/issue/9501 |\ | * 40d12f1 (origin/pull/4790) SI-9501 link README to Scala Hacker Guide * e0b5891 Merge pull request #4786 from performantdata/issue/9506 * 39acad8 (origin/pull/4786) SI-9506 suppress Scala IDE-generated files in the Eclipse project dirs * 74dc364 SI-9506 suppress Scala IDE-generated files in the Eclipse project dirs % git merge ae5f0de Auto-merging src/repl/scala/tools/nsc/interpreter/ILoop.scala Auto-merging src/library/scala/util/Either.scala Auto-merging src/library/scala/runtime/Tuple3Zipped.scala Auto-merging src/library/scala/runtime/Tuple2Zipped.scala Auto-merging src/library/scala/collection/parallel/ParIterableLike.scala Auto-merging src/library/scala/collection/immutable/ListMap.scala Auto-merging src/library/scala/collection/TraversableLike.scala Auto-merging src/eclipse/test-junit/.classpath CONFLICT (content): Merge conflict in src/eclipse/test-junit/.classpath Auto-merging src/eclipse/scaladoc/.classpath CONFLICT (content): Merge conflict in src/eclipse/scaladoc/.classpath Auto-merging src/eclipse/scala-compiler/.classpath Auto-merging src/eclipse/repl/.classpath CONFLICT (content): Merge conflict in src/eclipse/repl/.classpath Auto-merging src/eclipse/partest/.classpath CONFLICT (content): Merge conflict in src/eclipse/partest/.classpath Auto-merging src/eclipse/interactive/.classpath Auto-merging README.md Automatic merge failed; fix conflicts and then commit the result. % git checkout --ours src/eclipse/partest/.classpath % git checkout --ours src/eclipse/repl/.classpath % git checkout --ours src/eclipse/scaladoc/.classpath % git checkout --ours src/eclipse/test-junit/.classpath % git add -u % emacs test/junit/scala/collection/mutable/OpenHashMapTest.scala % git diff test/junit/scala/collection/mutable/OpenHashMapTest.scala | cat ... - val field = m.getClass.getDeclaredField("scala$collection$mutable$OpenHashMap$$deleted") + val field = m.getClass.getDeclaredField("deleted") ... % git add -u
| | * Merge pull request #4798 from performantdata/issue/9513Seth Tisue2015-10-151-0/+42
| | |\ | | | | | | | | SI-9513 decrement "deleted" count in OpenHashMap.put() when slot reused
| | | * Suppress unneeded import.Performant Data LLC2015-10-141-2/+2
| | | |
| | | * SI-9513 decrement "deleted" count in OpenHashMap.put() when slot reusedPerformant Data LLC2015-10-101-0/+42
| | | |
| | * | Merge pull request #4771 from som-snytt/issue/9492-hereSeth Tisue2015-10-142-0/+46
| | |\ \ | | | |/ | | |/| SI-9492 REPL paste here doc
| | | * SI-9492 REPL paste here docSom Snytt2015-09-272-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Simple here documentish syntax for REPL paste. This makes it easier to paste a block of script (as opposed to transcript). It also means you won't accidentally ctl-D out of the REPL and then out of SBT and then out of the terminal window. ``` scala> :paste < EOF // Entering paste mode (EOF to finish) class C { def c = 42 } EOF // Exiting paste mode, now interpreting. defined class C scala> new C().c res0: Int = 42 scala> :paste <| EOF // Entering paste mode (EOF to finish) |class D { def d = 42 } EOF // Exiting paste mode, now interpreting. defined class D scala> new D().d res1: Int = 42 scala> :quit ```
* | | | Allow @inline/noinline at callsites (in addition to def-site)Lukas Rytz2015-10-202-12/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow annotating individual callsites @inline / @noinline using an annotation ascription c.foo(): @inline
* | | | Correctly handle post-inline requests of non-existing callsitesLukas Rytz2015-10-201-4/+36
| | | | | | | | | | | | | | | | | | | | | | | | A post-inline request is allowed to refer to a callsite that does not exist anymore because it was alredy inlined while handling some other inline request, or because it was DCE'd.
* | | | Simplify post inlining requestsLukas Rytz2015-10-203-128/+40
| | | | | | | | | | | | | | | | Clean up inliner test
* | | | Don't create inline requests for callsites that cannot be inlinedLukas Rytz2015-10-202-20/+94
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When traversing the call graph and collecting inline reqeusts, rule out callsites that we already know cannot be inlined. Note that we cannot perform all necessary checks already at this stage: checks that depend on the callee body (the inlined code) are deferred until the callsite is actually inlined. The reason is that the code may change. Example: @inline final def f = try 1 catch { case _: Throwable => 2 } @inline final def g = f def t = println(g) When collecting inline requests, the body of g invokes the public method f, so g could be inlined into t. However, once f is inlined into g, the body of g contains a try-catch block. Now we cannot inline g into t anymore, because the call stack at the g callsite is non-empty (the stack is cleared when entering a handler).
* | | Merge commit 'bb3ded3' into merge-2.11-to-2.12-oct-5Lukas Rytz2015-10-0513-5/+167
|\| |
| * | Merge pull request #4720 from retronym/ticket/9029Jason Zaugg2015-09-2912-5/+148
| |\ \ | | |/ | |/| SI-9029 Fix regression in extractor patterns
| | * SI-7850 Additional tests for name based patmatJason Zaugg2015-09-212-0/+28
| | | | | | | | | | | | Found these in an old review branch of mine.
| | * SI-8989 Better error message for invalid extractor patternJason Zaugg2015-09-215-5/+51
| | |
| | * SI-9029 Fix regression in extractor patternsJason Zaugg2015-09-215-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The unified treatment of classical and named-based pattern matching does not correctly handle the generalization of "tuple capture". By "tuple capture", I mean: ``` scala> object Extractor { def unapply(a: Any): Option[(Int, String)] = Some((1, "2")) } defined object Extractor scala> "" match { case Extractor(x: Int, y: String) => } scala> "" match { case Extractor(xy : (Int, String)) => } warning: there was one deprecation warning; re-run with -deprecation for details scala> :warnings <console>:9: warning: object Extractor expects 2 patterns to hold (Int, String) but crushing into 2-tuple to fit single pattern (SI-6675) "" match { case Extractor(xy : (Int, String)) => } ^ ``` Name based pattern matching, new in Scala 2.11, allows one to deconstruct the elements that structurally resembles `ProductN`: ``` scala> class P2(val _1: Int, val _2: String) defined class P2 scala> object Extractor { def unapply(a: Any): Option[P2] = Some(new P2(1, "2")) } defined object Extractor scala> "" match { case Extractor(x: Int, y: String) => } ``` However, attempting to extract the `P2` in its entirety leads to an internal error: ``` scala> "" match { case Extractor(p2: P2) => } <console>:10: warning: fruitless type test: a value of type (Int, String) cannot also be a P2 "" match { case Extractor(p2: P2) => } ^ <console>:10: error: error during expansion of this match (this is a scalac bug). The underlying error was: type mismatch; found : P2 required: (Int, String) "" match { case Extractor(p2: P2) => } ^ ``` Note that this match was legal and warning free in 2.10. This commit avoids the hard-coded assumption that the "tuple capture" results in a `TupleN`, and instead keeps track of the product-ish type from which we extracted the element types. I have also opted not to limit the deprecation warning to `TupleN` extractors.
| * | Improve presentation compilation of annotationsJason Zaugg2015-09-241-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A trio of problems were hampering autocompletion of annotations. First, given that that annotation is written before the annotated member, it is very common to end parse incomplete code that has a floating annotation without an anotatee. The parser was discarding the annotations (ie, the modifiers) and emitting an `EmptyTree`. Second, the presetation compiler was only looking for annotations in the Modifiers of a member def, but after typechecking annotations are moved into the symbol. Third, if an annotation failed to typecheck, it was being discarded in place of `ErroneousAnnotation`. This commit: - modifies the parser to uses a dummy class- or type-def tree, instead of EmptyTree, which can carry the annotations. - updates the locator to look in the symbol annotations of the modifiers contains no annotations. - uses a separate instance of `ErroneousAnnotation` for each erroneous annotation, and stores the original tree in its `original` tree.
| * | Support completion in erroneous string interpolation.Jason Zaugg2015-09-241-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the code: ``` s"${fooo<CURSOR" ``` The parser treats `fooo` as a interpolator ID for the quote that we actually intend to end the interpolated string. Inserting a space (in addition to `__CURSOR__` that we already patch in to avoid parsing a partial identifier as a keyword), solves this problem.
| * | Merge pull request #4757 from lrytz/t9375-2.11Lukas Rytz2015-09-227-7/+356
| |\ \ | | | | | | | | [backport] SI-9375 add synthetic readResolve only for static modules
| | * | [backport] SI-9375 add synthetic readResolve only for static modulesLukas Rytz2015-09-227-7/+356
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | For inner modules, the synthetic readResolve method would cause the module constructor to be invoked on de-serialization in certain situations. See the discussion in the ticket. Adds a comprehensive test around serializing and de-serializing modules.
* | | Merge pull request #4769 from retronym/topic/anyrefmap-serializableLukas Rytz2015-10-051-2/+3
|\ \ \ | | | | | | | | Make AnyRefMap serializable
| * | | Make AnyRefMap serializableJason Zaugg2015-09-251-2/+3
| | | |
* | | | SI-9498 Avoid caching bug with pattern type variablesJason Zaugg2015-09-301-0/+25
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Typechecking a pattern that defines a pattern type variable initially assigns abstract type symbol with open type bounds. Later on, pattern type inference kicks in to sharpen the type of the variable based on constraints imposed by the expected type (ie, the type of scrutinee of the pattern.) However, before inference does this, a `TypeRef` to the abstract type symbol can be queried for its base type with respect to some class, which leads to it populating an internal cache. This cache becomes stale when the underlying symbol has its type mutated. The repercussions of this meant that a subsequent call to `baseType` gave the wrong result (`NoType`), which lead to an `asSeenFrom` operation to miss out of substitution of a type variable. Note the appearance of `A` in the old type errors in the enclosed test case. This commit takes an approach similar to 286dafbd to invalidate caches after the mutation. I've routed both bandaids through the same first aid kit: I'm sure over time we'll add additional calls to this method, and additional cache invalidations within it.
* | | Merge pull request #4764 from lrytz/sd-33Jason Zaugg2015-09-241-25/+43
|\ \ \ | | | | | | | | SD-33 Consider methods annotated @CallerSensitive not safe to inline
| * | | SD-33 Consider methods annotated @CallerSensitive not safe to inlineLukas Rytz2015-09-231-25/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes https://github.com/scala/scala-dev/issues/33 Methods annotated `sun.reflect.CallerSensitive` should not be inlined, their implementation may depend on the call stack.
* | | | Add $deserializeLambda$ when inlining an indyLambda into a classLukas Rytz2015-09-231-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes https://github.com/scala/scala-dev/issues/39 When inlining an indyLambda closure instantiation into a class, and the closure type is serializable, make sure that the target class has the synthetic `$deserializeLambda$` method.
* | | | Rename the Analyzers backend component to BackendUtilsLukas Rytz2015-09-233-3/+3
|/ / / | | | | | | | | | | | | Until now, there was no good place to hold various utility functions that are used acrosss the backend / optimizer.
* | | Merge commit '03aaf05' into merge-2.11-to-2.12-sep-22Lukas Rytz2015-09-2219-152/+258
|\| |
| * | Merge pull request #4725 from retronym/topic/completely-2.11Lukas Rytz2015-09-2112-43/+197
| |\ \ | | | | | | | | Topic/completely 2.11
| | * \ Merge remote-tracking branch 'origin/2.11.x' into topic/completely-2.11Jason Zaugg2015-09-1776-0/+39
| | |\ \