summaryrefslogtreecommitdiff
path: root/test/junit
Commit message (Collapse)AuthorAgeFilesLines
* SI-9515 closure elimination also for non-Scala-Function SAM typesLukas Rytz2016-07-041-0/+20
| | | | | | | | | | Also logged in as SD-162 The optimizer had conservative checks in place to perform closure elimination only for Scala Function types. We can eliminate IndyLambda instructions for any functional interface. LambdaMetaFactory only constructs lambda objects for interface types, which don't have any side-effects on construction - they don't have a constructor.
* Emit trait method bodies in staticsJason Zaugg2016-06-287-28/+67
| | | | | | | | | | | | | | | | | | | | And use this as the target of the default methods or statically resolved super or $init calls. The call-site change is predicated on `-Yuse-trait-statics` as a stepping stone for experimentation / bootstrapping. I have performed this transformation in the backend, rather than trying to reflect this in the view from Scala symbols + ASTs. We also need to add an restriction related to invokespecial to Java parents: to support a super call to one of these to implement a super accessor, the interface must be listed as a direct parent of the class. The static method names has a trailing $ added to avoid duplicate name and signature errors in classfiles.
* Keep line numbers when inlining from the same compilation unitLukas Rytz2016-06-062-1/+49
| | | | | | | | So far, line numbers were kept only when inlining from the same class. We can also keep them when inlining from a different class defined in the same compilation unit. Longer-term we should support JSR-45, see SI-7518 and scala-dev#3.
* SI-9256 check companions in same compilation unit only if same runLukas Rytz2016-06-063-17/+29
|
* clear all flags when resetting a symbolLukas Rytz2016-06-061-0/+11
| | | | | | this change is a bit scary because it changes code that's not been changed in 11 years https://github.com/scala/scala/commit/7fa7c93#diff-d5789e5ae5061197d782d08324b260dbL214
* Store source file paths of classes being compiled in the bytecode repoLukas Rytz2016-06-062-2/+2
| | | | | | | For classes being compiled (vs. being loaded from classfiles), keep the source file path in the bytecode repo. This will allow to keep line numbers when inlining from one class into another in case the two are defined in the same compilation unit.
* Merge pull request #5099 from retronym/ticket/9390Jason Zaugg2016-06-062-3/+3
|\ | | | | SI-9390 Emit local defs that don't capture this as static
| * SI-9390 Emit local defs that don't capture this as staticJason Zaugg2016-06-012-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | This avoids unnecessary memory retention, and allows lambdas that call the local methods to be serializable, regardless of whether or not the enclosing class is serializable. The second point is especially pressing, given that the enclosing class for local methods defined in a used to be the (serializable) anonymous function class, but as of Scala 2.12 will be the enclosing class of the lambda. This change is similar in spirit to SI-9408 / 93bee55e.
* | Merge pull request #5157 from retronym/topic/lambda-staticsJason Zaugg2016-06-067-41/+47
|\| | | | | Lambda impl methods static and more stably named
| * Treat self parameter as non-null in the optimizerLukas Rytz2016-06-012-2/+2
| |
| * Lambda impl methods static and more stably namedJason Zaugg2016-06-016-40/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The body of lambdas is compiled into a synthetic method in the enclosing class. Previously, this method was a public virtual method named `fully$qualified$Class$$anonfun$n`. For lambdas that didn't capture a `this` reference, a static method was used. This commit changes two aspects. Firstly, all lambda impl methods are now emitted static. An extra parameter is added to those that require a this reference. This is an improvement as it: - allows, shorter, more readable names for the lambda impl method - avoids pollution of the vtable of the class. Note that javac uses private instance methods, rather than public static methods. If we followed its lead, we would be unable to support important use cases in our inliner Secondly, the name of the enclosing method has been included in the name of the lambda impl method to improve debuggability and to improve serialization compatibility. The serialization improvement comes from the way that fresh names for the impl methods are allocated: adding or removing lambdas in methods not named "foo" won't change the numbering of the `anonfun$foo$n` impl methods from methods named "foo". This is in line with user expectations about anonymous class and lambda serialization stability. Brian Goetz has described this tricky area well in: http://cr.openjdk.java.net/~briangoetz/eg-attachments/lambda-serialization.html This commit doesn't go as far a Javac, we don't use the hash of the lambda type info, param names, etc to map to a lambda impl method name. As such, we are more prone to the type-1 and -2 failures described there. However, our Scala 2.11.8 has similar characteristics, so we aren't going backwards. Special case in the naming: Use "new" rather than "<init>" for constructor enclosed lambdas, as javac does. I have also changed the way that "delambdafy target" methods are identifed. Rather than relying on the naming convention, I have switched to using a symbol attachment. The assumption is that we only need to identify them from within the same compilation unit. This means we can distinguish impl metbods for expanded functions (ones called from an `apply` method of an ahead-of-time expanded anonfun class), from those that truly end up as targets for lambda metafactory. Only the latter are translated to static methods in this patch.
* | Merge pull request #5207 from lrytz/nan-compareAdriaan Moors2016-06-021-0/+38
|\ \ | | | | | | Fix comparisons involving NaN
| * | Fix comparisons involving NaNLukas Rytz2016-06-021-0/+38
| | | | | | | | | | | | | | | Floating point comparisons involving NaN should always return false, except for !=. Fixes a regression introduced by #4963.
* | | Merge commit '4196569' into merge-2.11-to-2.12-june-1Lukas Rytz2016-06-011-0/+48
|\ \ \ | |/ / |/| |
| * | SI-9688 Make merge in immutable HashMap1 work with null kv.Łukasz Gieroń2016-05-231-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | The kv field of scala.collection.immutable.HashMap.HashMap1 can be null. This commit corrects the behavior of updated0 (which is on call path for merged) to work in such cases, instead of throwing NPE. Commit contains regression test.
* | | SI-9767 document and test behaviour of String->integer/float conversionsMike Pheasant2016-06-011-0/+31
| |/ |/| | | | | | | | | | | We delegate `String`'s extension methods `toInt`, `toFloat`, etc to corresponding methods in the Java standard library. These differ in the way they handle whitespace in the original string. This commit documents and tests the current behaviour.
* | Merge pull request #5076 from soc/topic/deprecations-sinceLukas Rytz2016-05-301-1/+1
|\ \ | | | | | | Improvements to deprecations related to `since` parameter
| * | Add since arg to deprecationWarning and use itSimon Ochsenreither2016-05-291-1/+1
| | |
* | | Merge pull request #5191 from som-snytt/issue/9382Lukas Rytz2016-05-302-16/+68
|\ \ \ | |/ / |/| | SI-9382 Privatize enhanced x in Tuple2Zipped.Ops
| * | SI-9382 Zippy clean-up in aisle 2 & 3Som Snytt2016-05-262-16/+68
| | | | | | | | | | | | | | | Consolated JUnit tests and heeded comment about private def and code beauty.
* | | Merge pull request #5102 from milessabin/2.12.xJason Zaugg2016-05-271-3/+3
|\ \ \ | | | | | | | | SI-2712 Add support for partial unification of type constructors
| * | | -Xexperimental mode now only includes -Ypartial-unificationMiles Sabin2016-05-241-3/+3
| |/ /
* | | Merge pull request #5186 from lrytz/inlinerM5Jason Zaugg2016-05-271-5/+5
|\ \ \ | | | | | | | | Debug flag to print a summary of the inliner's work
| * | | Debug flag to print a summary of the inliner's workLukas Rytz2016-05-241-5/+5
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Example output below. Note that inlining List.map fails because the trait forwarder uses `INVOKESPECIAL` for now, will change with pr 5177. $ cat Test.scala class C { def foo = Map(1 -> 'a', 2 -> 'b') def bar(l: List[Int]) = l.map(_ + 1) } $ qsc -Yopt-log-inline _ -Yopt:l:classpath Test.scala Inlining into C.foo (initially 36 instructions, ultimately 72): - Inlined scala/Predef$ArrowAssoc$.$minus$greater$extension (8 instructions) 2 times: the callee is annotated `@inline` Inlining into C.bar (initially 12 instructions, ultimately 12): - Failed to inline scala/collection/immutable/List.map (the callee is a higher-order method, the argument for parameter (bf: Function1) is a function literal): The callee scala/collection/immutable/List::map(Lscala/Function1;Lscala/collection/generic/CanBuildFrom;)Ljava/lang/Object; contains the instruction INVOKESPECIAL scala/collection/TraversableLike.map (Lscala/Function1;Lscala/collection/generic/CanBuildFrom;)Ljava/lang/Object; that would cause an IllegalAccessError when inlined into class C.
* | | Merge pull request #5192 from dwijnand/wip/scala-repl-no-importsJason Zaugg2016-05-271-0/+19
|\ \ \ | | | | | | | | Fully qualify types in REPL generated code
| * | | Fully qualify types in REPL generated codeDale Wijnand2016-05-261-0/+19
| | | |
* | | | Rename -Yopt to -opt, -Yopt-warnings to -opt-warningsLukas Rytz2016-05-2521-33/+33
|/ / / | | | | | | | | | Keep -Yopt-inline-heuristics and -Yopt-trace unchanged
* / / SI-9522 release key reference when deleting from OpenHashMapPerformant Data LLC2016-05-241-1/+57
|/ / | | | | | | | | | | | | | | | | This sets the key field in the hash table entry to its default value when an entry is deleted, so as not to unexpectedly retain an object reference, leading to a memory leak. Also includes incidental changes to the slot location algorithm that reduce the number of deleted entries.
* | SI-9121 test case (fixed in new optimizer), SI-9179 test caseLukas Rytz2016-05-232-0/+54
| | | | | | | | | | Also adds a mising phase travel in the backend. A comment already points out why it's necessary, but it was actually forgotten.
* | Merge pull request #5180 from lrytz/junit-passJason Zaugg2016-05-2346-2036/+2051
|\ \ | | | | | | Clean up JUnit tests, make sure they pass without bootstrap [ci: last-only]
| * | Adapt naming convention for collection.convert null safety testLukas Rytz2016-05-203-279/+286
| | | | | | | | | | | | | | | | | | | | | Test classes not ending in "Test" are not executed in sbt. IntelliJ runs them. After this patch: 803 tests executed both in sbt and junit.
| * | All JUnit tests pass without bootstrap (when run in intellij, sbt)Lukas Rytz2016-05-203-92/+123
| | |
| * | Split RunTest and BytecodeTest into parts, put in matching packages.Lukas Rytz2016-05-2013-610/+660
| | |
| * | Cleanup in BytecodeTestLukas Rytz2016-05-201-28/+20
| | |
| * | Small cleanup in JUnit testLukas Rytz2016-05-201-5/+1
| | |
| * | Clean up bytecode testing methods.Lukas Rytz2016-05-2022-462/+496
| | |
| * | Better abstraction for JUnit run testsLukas Rytz2016-05-202-11/+22
| | |
| * | Better abstraction for bytecode tests. Also organize some imports.Lukas Rytz2016-05-2030-555/+453
| | |
| * | Rename nsc.backend.jvm.CodeGenTools to testing.BytecodeTestingLukas Rytz2016-05-2030-39/+35
| | |
* | | SI-7916: ScriptEngine supportSom Snytt2016-05-191-0/+83
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor the ScriptEngine support to an adaptor atop the IMain API. Allow references to resolve to context attributes. (The attributes must be defined at compilation time, though they may resolve to updated values at evaluation time.) This means that attributes are not bound statically in REPL history. In particular, we forgo the trick of binding attributes named "name: Type" as typed values. Instead, an `x` bound in dynamic context is injected into the script as a dynamic selection `$ctx.x` where `ctx` performs the look-up in the script context. When a compiled script is re-evaluated, a new instance of the script class is created and defined symbols are rebound. The context stdout writer is handled with `Console.withOut`, with bytes decoded using the default charset. Compilation errors are thrown as ScriptException with the first reported error. This commit doesn't attempt dynamic selection from objects in context. Currently, script must cast.
* | SI-9066 fix null.asInstanceOf[Unit]Lukas Rytz2016-05-182-23/+23
| |
* | SI-9671, SI-7397 fix null.asInstanceOf[Int] when pt erases to ObjectLukas Rytz2016-05-183-10/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Erasure first replaces null.asInstanceOf[Int] by unbox(null). If the expected type erases to object, erasure then introduces a box operation, yielding box(unbox(null)). Note that this value is a box of zero, not null. Erasure has an optimization to replace box(unbox(x)) in case x is of primitive type. 60f1b4b extended this to the case when x is null, which is incorrect in general. The reason was to prevent creating a primitive box to be stored in the unused generic field when creating an instance of a specialized class. A special case ensures that this optimization is still performed.
* | Merge pull request #5103 from ruippeixotog/improve-list-map-set-perfLukas Rytz2016-05-172-0/+101
|\ \ | | | | | | Improve performance and behavior of ListMap and ListSet
| * | Improve performance and behavior of ListMap and ListSetRui Gonçalves2016-05-172-0/+101
| | | | | | | | | | | | | | | | | | | | | | | | Makes the immutable `ListMap` and `ListSet` collections more alike one another, both in their semantics and in their performance. In terms of semantics, makes the `ListSet` iterator return the elements in their insertion order, as `ListMap` already does. While, as mentioned in SI-8985, `ListMap` and `ListSet` doesn't seem to make any guarantees in terms of iteration order, I believe users expect `ListSet` and `ListMap` to behave in the same way, particularly when they are implemented in the exact same way. In terms of performance, `ListSet` has a custom builder that avoids creation in O(N^2) time. However, this significantly reduces its performance in the creation of small sets, as its requires the instantiation and usage of an auxilliary HashSet. As `ListMap` and `ListSet` are only suitable for small sizes do to their performance characteristics, the builder is removed, the default `SetBuilder` being used instead.
* | | Reduce boilerplate in compiler JUnit tests (#5158)Jason Zaugg2016-05-1625-258/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many JUnit tests share a compiler instance between all test cases in a class to reduce overhead. This commit refactors the mechanism to reduce the boilerplate. In the new scheme: - Using the `@ClassRule` hook in JUnit, we create a per-class map for each test class. - Per-class values are registered from the test class itself by calling `cached("someKey", () => mkExpensiveThing)` - At the end of the test, the entries in this map are `close()`-ed (if they implement `Closable`), and are released for garbage collection.)
* | | SI-9666: Use inline group names in Regex (#4990)som-snytt2016-05-111-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Delegate `Match group name` to the underlying `matcher`. If that fails, try explicit group names as a fall back. No attempt is made to correlate inline and explicit names. In the following case, either name is accepted: ``` new Regex("a(?<Bar>b*)c", "Bee") ``` But if names are reversed, the error is undetected: ``` new Regex("a(?<Bee>b*)(?<Bar>c)", "Bar", "Bee") ``` Throw IllegalArg on bad group name to be consistent with Java.
* | | Merge pull request #5112 from lrytz/dropRecursiveClasspathJason Zaugg2016-05-054-232/+24
|\ \ \ | | | | | | | | Remove legacy recursive classpath implementation
| * | | Remove abstraction layer in classpath implementationLukas Rytz2016-05-023-29/+24
| | | |
| * | | remove recursive classpath implementationLukas Rytz2016-04-233-206/+3
| | | |
* | | | Merge pull request #5132 from acdenhartog/patch-1Jason Zaugg2016-05-051-0/+7
|\ \ \ \ | | | | | | | | | | Avoid function chaining with reverse method