summaryrefslogtreecommitdiff
path: root/test/junit
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #4638 from lrytz/t9393Jason Zaugg2015-07-241-0/+96
|\ | | | | SI-9393 fix modifiers of ClassBTypes for Java annotations
| * Query methods in api.Symbols for Java flagsLukas Rytz2015-07-221-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds query methods to the public reflection API for querying the JAVA_ENUM and JAVA_ANNOTATION flags. Didn't include JAVA_DEFAULTMETHOD because it does not correspond to a real java classfile flag (just a non-abstract method in an interface), and we want to clean the usage of this flag before adding it to a public API. The flags themselfs are not added to the reflection API. A comment in api/FlagSets.scala says: Q: I have a pretty flag. Can I put it here? A: Only if there's a tree that cannot be built without it. If you want to put a flag here so that it can be tested against, introduce an `isXXX` method in one of the api.Symbols classes instead.
| * SI-9393 fix modifiers of ClassBTypes for Java annotationsLukas Rytz2015-07-221-0/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Scala classfile and java source parsers make Java annotation classes (which are actually interfaces at the classfile level) look like Scala annotation classes: - the INTERFACE / ABSTRACT flags are not added - scala.annotation.Annotation is added as superclass - scala.annotation.ClassfileAnnotation is added as interface This makes type-checking @Annot uniform, whether it is defined in Java or Scala. This is a hack that leads to various bugs (SI-9393, SI-9400). Instead the type-checking should be special-cased for Java annotations. This commit fixes SI-9393 and a part of SI-9400, but it's still easy to generate invalid classfiles. Restores the assertions that were disabled in #4621. I'd like to leave these assertions in: they are valuable and helped uncovering the issue being fixed here. A new flag JAVA_ANNOTATION is introduced for Java annotation ClassSymbols, similar to the existing ENUM flag. When building ClassBTypes for Java annotations, the flags, superclass and interfaces are recovered to represent the situation in the classfile. Cleans up and documents the flags space in the area of "late" and "anti" flags. The test for SI-9393 is extended to test both the classfile and the java source parser.
* | Merge pull request #4647 from Ichoran/issue/8911Lukas Rytz2015-07-231-0/+29
|\ \ | | | | | | SI-8911 allow serializing Scala Maps wrapped as Java ones
| * | SI-8911 scala.collection.convert.Wrappers$MapWrapper not serializableRex Kerr2015-07-191-0/+29
| |/ | | | | | | | | | | | | | | Added `with Serializable` to `MapWrapper` and `SetWrapper`. Test verifies that serialization works in the simplest case. Also updated tests in t8549 to check that serialization works and doesn't change.
* | Merge remote-tracking branch 'origin/2.11.x' into ↵Jason Zaugg2015-07-231-1/+1
|\ \ | |/ |/| | | merge/2.11.x-to-2.12.x-20152307
| * Improve some names (t-v)Janek Bogucki2015-07-151-1/+1
| |
* | Merge pull request #4611 from SethTisue/issue/8627Lukas Rytz2015-07-161-1/+3
|\ \ | | | | | | add test coverage for SI-8627 (Stream.filterNot)
| * | add test coverage for SI-8627 (Stream.filterNot)Seth Tisue2015-07-081-1/+3
| | |
* | | Merge pull request #4622 from retronym/merge/2.11.x-to-2.12.x-20150713Adriaan Moors2015-07-132-2/+2
|\ \ \ | | | | | | | | Merge 2.11.x to 2.12.x [ci: last-only]
| * \ \ Merge remote-tracking branch 'origin/2.11.x' into ↵Jason Zaugg2015-07-132-2/+2
| |\ \ \ | | |/ / | |/| / | | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | merge/2.11.x-to-2.12.x-20150713 Conflicts: src/eclipse/partest/.classpath src/eclipse/repl/.classpath test/files/run/nothingTypeNoFramesNoDce.scala test/files/run/repl-javap-app.check Also fixup two .classpath files with updated partest, xml and parser combinators JARs.
| | * Fix 23 typos (m-o)Janek Bogucki2015-06-282-2/+2
| | |
* | | Merge pull request #4609 from retronym/topic/indylambda-testLukas Rytz2015-07-092-1/+58
|\ \ \ | | | | | | | | [indylambda] Improve test coverage
| * | | Address review feedbackJason Zaugg2015-07-092-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | - Add requisite boilerplate for test cleanup to IndyLambdaTest - ... and to the spot where I copy/pasted the wrong code from - Fix comment.
| * | | [indylambda] Improve test coverageJason Zaugg2015-07-081-0/+54
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding tests for the selective use of boxing bridge methods and to show that specialization is not subverted by indylambda. Other aspects of indylambda are tested by tests like: - run/lambda-serialization.scala - run/indylambda-boxing When those tests were written, they only tested the old backend. However, now that we have Java 8 and the new backend avaialble by default to partest, they provide the intended coverage.
* | | Merge pull request #4607 from lrytz/inlineIndyAdriaan Moors2015-07-081-0/+37
|\ \ \ | | | | | | | | Accessibility checks for methods with an InvokeDynamic instruction
| * | | Accessibility checks for methods with an InvokeDynamic instructionLukas Rytz2015-07-071-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implements the necessary tests to check if a method with an InvokeDynamic instruction can be inlined into a destination class. Only InvokeDynamic instructions with LambdaMetaFactory as bootstrap methods can be inlined. The accessibility checks cannot be implemented generically, because it depends on what the bootstrap method is doing. In particular, the bootstrap method receives a Lookup object as argument which can be used to access private methods of the class where the InvokeDynamic method is located. A comment in the inliner explains the details.
* | | | Merge pull request #4602 from lrytz/yoptInScalaAdriaan Moors2015-07-083-1/+117
|\| | | | |/ / |/| | Fix optimizer bugs and enable -Yopt:l:classpath when building scala
| * | Set -Xsource to 2.12 by defaultLukas Rytz2015-07-031-1/+1
| | |
| * | Prevent infinite recursion in ProdConsAnalyzerLukas Rytz2015-07-031-0/+42
| | | | | | | | | | | | | | | | | | When an instruction is its own producer or consumer, the `initialProducer` / `ultimateConsumer` methods would loop. While loops or @tailrec annotated methods can generate such bytecode.
| * | SI-9376 don't crash when inlining a closure body that throws.Lukas Rytz2015-07-031-0/+74
| | | | | | | | | | | | | | | | | | | | | | | | If the closure body method has return type Nothing$, add an `ATHROW` instruction after the callsite. This is required for computing stack map frames, as explained in a comment in BCodeBodyBuilder.adapt. Similar for closure bodies with return type Null$.
* | | Merge pull request #4561 from jdevelop/io-source-fromclasspath-2.12Adriaan Moors2015-07-071-0/+4
|\ \ \ | |/ / |/| | SI-7514 Introduce Source.fromResource(...) method
| * | [ SI-7514 ] Introduce Source.fromClassPath(resource) methodEugene Dzhurinsky2015-07-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Creates Source from named classpath resource. Simplifies val src = io.Source.fromInputStream(classOf[ClassInst].getResourceAsStream("/name")) to val src = io.Source.fromClassPath("/name")
* | | SI-9377 Update ScalaVersion error textSom Snytt2015-07-022-1/+5
| | | | | | | | | | | | Simplify and sweeten the message.
* | | SI-9377 ScalaVersion init no longer fails if versionlessSom Snytt2015-07-021-0/+5
|/ / | | | | | | | | | | If the version string was empty, ScalaVersion would indignantly refuse to initialize. Now it takes a missing property as "none".
* | Include sources for scala-java8-compat instead of jarLukas Rytz2015-07-011-0/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit e1895d64f87dc3c699a3ccbc8a3143b18d3b5bb1, titled "Add scala-java8-compat to scala-library.jar". Move SAM functions and `LambdaDeserializer` (from scala/scala-java8-compat@9253ed9) into `scala.runtime.java8` package under `src/library`. (The package name is the only diff -- they were in `scala.compat.java8` before). The original LambdaDeserializer: https://github.com/scala/scala-java8-compat/blob/c0732e6/src/main/java/scala/compat/java8/runtime/LambdaDeserializer.scala
* | Merge commit 'bb102e7' into merge-2.11-to-2.12-june-26Lukas Rytz2015-06-263-12/+262
|\|
| * Merge pull request #4552 from lrytz/opt/closureInliningJason Zaugg2015-06-243-12/+262
| |\ | | | | | | Closure elimination for new backend
| | * Producers / Consumers AnalysisLukas Rytz2015-06-223-12/+262
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ASM has a built-in `SourceValue` analysis which computes for each value a set of instructions that may possibly have constructed it. The ProdConsAnalyzer class provides additional queries over the result of the SourceValue analysis: - consumers of values - tracking producers / consumers through copying operations (load, store, etc) A fix to (and therefore a new version of) ASM was required. See here: https://github.com/scala/scala-asm/commit/94106a5472
* | | Default to delambdafy:method and backend:GenBCodeLukas Rytz2015-06-261-3/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Switch the defaults of `-Ydelambdafy` and `-Ybackend`. Rewrite t6288b-jump-position test - no more icode Don't crash GenBCode beyond JVM code size limits A similar patch is in GenASM, see 3fa2c97 Fix check files for GenBCode / delambdafy:method defaults Force copy propagation test to ASM, see SI-9364 Force inline-ex-handlers test to GenASM, see SI-9364 Move t6613 test to pending - still broken in GenBCode Adding a `flags` file with `-Ybackend:GenASM` doesn't seem to have the desired effect. SI-6613 is re-opened. Force a few tests to GenASM, see SI-9364
* | | Merge pull request #4504 from ruippeixotog/mutable-treemapAdriaan Moors2015-06-251-2/+4
|\ \ \ | | | | | | | | SI-4147 Add an implementation of `mutable.TreeMap`
| * | | SI-4147 Add an implementation of `mutable.TreeMap`Rui Gonçalves2015-05-301-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit contains an implementation of a mutable red-black tree with focus on performance. It also contains a new `mutable.TreeMap` Scala collection that is backed by the aforementioned tree. The common generic factories and traits related to mutable sorted maps didn't exist yet, so this commit also adds them. Regarding performance, `TreeMap` overrides (from `MapLike` and `SortedMapLike`) all of the most common methods for maps and also those whose default implementations are asymptotically worse than direct red-black tree algorithms (e.g. `last`, `clear`). The `rangeImpl` method of `TreeMap` returns an instance of `TreeMapView`, an inner class of `TreeMap`. This view is backed by the same `RedBlackTree.Tree` instance, and therefore changes to the original map are reflected in the view and vice-versa. The semantics of mutating a view by adding and removing keys outside the view's range are the same of the current `mutable.TreeSet`. A bit less focus was given on the performance of views - in particular, getting the `size` of a `TreeMapView` is O(n) on the number of elements inside the view bounds. That can be improved in the future. In a future commit, `mutable.TreeSet` can be changed to be backed by this red-black tree implementation.
* | | | Merge pull request #4514 from martijnhoekstra/patch-2Adriaan Moors2015-06-251-0/+6
|\ \ \ \ | | | | | | | | | | Documentation for split [ci: last-only]
| * | | | StringLike.split fixed for surrogates and docmartijnhoekstra2015-05-281-0/+6
| |/ / / | | | | | | | | | | | | | | | | | | | | Reverts to calling String.split(re: String), but change escape to always put us on the JDK7 fast-path if possible, which is for everything but Chars representing surrogate codeunits
* | | | Merge branch '2.11.x' into merge/2.11.x-to-2.12.x-20150624Jason Zaugg2015-06-249-9/+408
|\ \ \ \ | |/ / / |/| / / | |/ /
| * / Fix 25 typos (g-i)Janek Bogucki2015-06-222-2/+2
| |/
| * Merge pull request #4529 from lrytz/inlineAccessibilityJason Zaugg2015-06-191-6/+10
| |\ | | | | | | Fix illegal inlining of instructions accessing protected members
| | * Fix illegal inlining of instructions accessing protected membersLukas Rytz2015-05-281-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There were two issues in the new inliner that would cause a VerifyError and an IllegalAccessError. First, an access to a public member of package protected class C can only be inlined if the destination class can access C. This is tested by t7582b. Second, an access to a protected member requires the receiver object to be a subtype of the class where the instruction is located. So when inlining such an access, we need to know the type of the receiver object - which we don't have. Therefore we don't inline in this case for now. This can be fixed once we have a type propagation analyis. https://github.com/scala-opt/scala/issues/13. This case is tested by t2106. Force kmpSliceSearch test to delambdafy:inline See discussion on https://github.com/scala/scala/pull/4505. The issue will go away when moving to indy-lambda.
| * | Merge pull request #4527 from nicky-zs/fix_BigDecimalLukas Rytz2015-06-181-0/+32
| |\ \ | | | | | | | | fix BigDecimal losing MathContext
| | * | make BigDecimalTest.testMathContext a bit easier to understandZhong Sheng2015-06-181-13/+14
| | | |
| | * | add more test for testMathContextZhong Sheng2015-05-291-2/+26
| | | |
| | * | add unit test for MathContext lostZhong Sheng2015-05-281-0/+7
| | |/
| * | SI-9348 Fix missing last element in exclusive floating point rangesNiko Vuokko2015-06-172-1/+38
| | | | | | | | | | | | | | | Fix exclusive floating point ranges to contain also the last element when the end-start difference is not an integer multiple of step.
| * | Merge pull request #4534 from Ichoran/sorting-reimplAdriaan Moors2015-06-161-0/+69
| |\ \ | | | | | | | | Clean implementation of sorts for scala.util.Sorting.
| | * | Clean implementation of sorts for scala.util.Sorting.Rex Kerr2015-06-011-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removed code based on Sun JDK sorts and implemented new (basic) sorts from scratch. Deferred to Java Arrays.sort whenever practical. Behavior of `scala.util.Sorting` should be unchanged, but changed documentation to specify when the Java methods are being used (as they're typically very fast). A JUnit test is provided. Performance is important for sorts. Everything is better with this patch, though it could be better yet, as described below. Below are sort times (in microseconds, SEM < 5%) for various 1024-element arrays of small case classes that compare on an int field (quickSort), or int arrays that use custom ordering (stableSort). Note: "degenerate" means there are only 16 values possible, so there are lots of ties. Times are all with fresh data (no re-using cache from run to run). Results: ``` random sorted reverse degenerate big:64k tiny:16 Old Sorting.quickSort 234 181 178 103 25,700 1.4 New Sorting.quickSort 170 27 115 74 18,600 0.8 Old Sorting.stableSort 321 234 236 282 32,600 2.1 New Sorting.stableSort 239 16 194 194 25,100 1.2 java.util.Arrays.sort 124 4 8 105 13,500 0.8 java.util.Arrays.sort|Box 126 15 13 112 13,200 0.9 ``` The new versions are uniformly faster, but uniformly slower than Java sorting. scala.util.Sorting has use cases that don't map easily in to Java unless everything is pre-boxed, but the overhead of pre-boxing is minimal compared to the sort. A snapshot of some of my benchmarking code is below. (Yes, lots of repeating myself--it's dangerous not to when trying to get somewhat accurate benchmarks.) ``` import java.util.Arrays import java.util.Comparator import math.Ordering import util.Sorting import reflect.ClassTag val th = ichi.bench.Thyme.warmed() case class N(i: Int, j: Int) {} val a = Array.fill(1024)( Array.tabulate(1024)(i => N(util.Random.nextInt, i)) ) var ai = 0 val b = Array.fill(1024)( Array.tabulate(1024)(i => N(i, i)) ) var bi = 0 val c = Array.fill(1024)( Array.tabulate(1024)(i => N(1024-i, i)) ) var ci = 0 val d = Array.fill(1024)( Array.tabulate(1024)(i => N(util.Random.nextInt(16), i)) ) var di = 0 val e = Array.fill(16)( Array.tabulate(65536)(i => N(util.Random.nextInt, i)) ) var ei = 0 val f = Array.fill(65535)( Array.tabulate(16)(i => N(util.Random.nextInt, i)) ) var fi = 0 val o = new Ordering[N]{ def compare(a: N, b: N) = if (a.i < b.i) -1 else if (a.i > b.i) 1 else 0 } for (s <- Seq("one", "two", "three")) { println(s) th.pbench{ val x = a(ai).clone; ai = (ai+1)%a.length; Sorting.quickSort(x)(o); x(x.length/3) } th.pbench{ val x = b(bi).clone; bi = (bi+1)%b.length; Sorting.quickSort(x)(o); x(x.length/3) } th.pbench{ val x = c(ci).clone; ci = (ci+1)%c.length; Sorting.quickSort(x)(o); x(x.length/3) } th.pbench{ val x = d(di).clone; di = (di+1)%d.length; Sorting.quickSort(x)(o); x(x.length/3) } th.pbench{ val x = e(ei).clone; ei = (ei+1)%e.length; Sorting.quickSort(x)(o); x(x.length/3) } th.pbench{ val x = f(fi).clone; fi = (fi+1)%f.length; Sorting.quickSort(x)(o); x(x.length/3) } } def ix(ns: Array[N]) = { val is = new Array[Int](ns.length) var i = 0 while (i < ns.length) { is(i) = ns(i).i i += 1 } is } val p = new Ordering[Int]{ def compare(a: Int, b: Int) = if (a > b) 1 else if (a < b) -1 else 0 } for (s <- Seq("one", "two", "three")) { println(s) val tag: ClassTag[Int] = implicitly[ClassTag[Int]] th.pbench{ val x = ix(a(ai)); ai = (ai+1)%a.length; Sorting.stableSort(x)(tag, p); x(x.length/3) } th.pbench{ val x = ix(b(bi)); bi = (bi+1)%b.length; Sorting.stableSort(x)(tag, p); x(x.length/3) } th.pbench{ val x = ix(c(ci)); ci = (ci+1)%c.length; Sorting.stableSort(x)(tag, p); x(x.length/3) } th.pbench{ val x = ix(d(di)); di = (di+1)%d.length; Sorting.stableSort(x)(tag, p); x(x.length/3) } th.pbench{ val x = ix(e(ei)); ei = (ei+1)%e.length; Sorting.stableSort(x)(tag, p); x(x.length/3) } th.pbench{ val x = ix(f(fi)); fi = (fi+1)%f.length; Sorting.stableSort(x)(tag, p); x(x.length/3) } } for (s <- Seq("one", "two", "three")) { println(s) th.pbench{ val x = a(ai).clone; ai = (ai+1)%a.length; Arrays.sort(x, o); x(x.length/3) } th.pbench{ val x = b(bi).clone; bi = (bi+1)%b.length; Arrays.sort(x, o); x(x.length/3) } th.pbench{ val x = c(ci).clone; ci = (ci+1)%c.length; Arrays.sort(x, o); x(x.length/3) } th.pbench{ val x = d(di).clone; di = (di+1)%d.length; Arrays.sort(x, o); x(x.length/3) } th.pbench{ val x = e(ei).clone; ei = (ei+1)%e.length; Arrays.sort(x, o); x(x.length/3) } th.pbench{ val x = f(fi).clone; fi = (fi+1)%f.length; Arrays.sort(x, o); x(x.length/3) } } def bx(is: Array[Int]): Array[java.lang.Integer] = { val Is = new Array[java.lang.Integer](is.length) var i = 0 while (i < is.length) { Is(i) = java.lang.Integer.valueOf(is(i)) i += 1 } Is } def xb(Is: Array[java.lang.Integer]): Array[Int] = { val is = new Array[Int](Is.length) var i = 0 while (i < is.length) { is(i) = Is(i).intValue i += 1 } is } val q = new Comparator[java.lang.Integer]{ def compare(a: java.lang.Integer, b: java.lang.Integer) = o.compare(a.intValue, b.intValue) } for (s <- Seq("one", "two", "three")) { println(s) val tag: ClassTag[Int] = implicitly[ClassTag[Int]] th.pbench{ val x = bx(ix(a(ai))); ai = (ai+1)%a.length; Arrays.sort(x, q); xb(x)(x.length/3) } th.pbench{ val x = bx(ix(b(bi))); bi = (bi+1)%b.length; Arrays.sort(x, q); xb(x)(x.length/3) } th.pbench{ val x = bx(ix(c(ci))); ci = (ci+1)%c.length; Arrays.sort(x, q); xb(x)(x.length/3) } th.pbench{ val x = bx(ix(d(di))); di = (di+1)%d.length; Arrays.sort(x, q); xb(x)(x.length/3) } th.pbench{ val x = bx(ix(e(ei))); ei = (ei+1)%e.length; Arrays.sort(x, q); xb(x)(x.length/3) } th.pbench{ val x = bx(ix(f(fi))); fi = (fi+1)%f.length; Arrays.sort(x, q); xb(x)(x.length/3) } } ```
| * | | Merge pull request #4519 from lrytz/opt/nullness-2.11Jason Zaugg2015-06-072-0/+247
| |\ \ \ | | |/ / | |/| | Nullness Analysis for GenBCode
| | * | Fix aliasing / nullness of CHECKCASTLukas Rytz2015-06-041-0/+26
| | | |
| | * | Address review feedbackLukas Rytz2015-05-251-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | Address feedback in #4516 / 57b8da4cd8. Save allocations of NullnessValue - there's only 4 possible instances. Also save tuple allocations in InstructionStackEffect.
| | * | Enable nullness analysis in the inlinerLukas Rytz2015-05-251-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When inlining an instance call, the inliner has to ensure that a NPE is still thrown if the receiver object is null. By using the nullness analysis, we can avoid emitting this code in case the receiver object is known to be not-null.
| | * | Nullness AnalysisLukas Rytz2015-05-221-0/+205
| | |/ | | | | | | | | | | | | | | | | | | | | | Tracks nullness of values using an ASM analyzer. Tracking nullness requires alias tracking for local variables and stack values. For example, after an instance call, local variables that point to the same object as the receiver are treated not-null.