summaryrefslogtreecommitdiff
path: root/src/library
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #5531 from tabdulradi/SI-10060Lukas Rytz2016-12-121-2/+2
|\ | | | | SI-10060 Fixes NumricRange.max bug on empty ranges
| * SI-10060 Fixes NumericRange.max bug on empty rangesTamer AbdulRadi2016-11-161-2/+2
| |
* | Merge pull request #5527 from som-snytt/fix/use-modern-replaceLukas Rytz2016-12-121-9/+3
|\ \ | | | | | | String.replaceAllLiterally is String.replace
| * | String.replaceAllLiterally is String.replaceSom Snytt2016-11-131-9/+3
| |/ | | | | | | | | The method is not deprecated outright because it avoids the overloaded equivalent.
* | Merge pull request #5569 from paplorinc/rotrLukas Rytz2016-12-122-19/+8
|\ \ | | | | | | Changed hashing bit rotation to use Integer.rotateRight
| * | Changed hashing bit rotation to use Integer.rotateRightPap Lőrinc2016-12-072-19/+8
| | |
* | | Applied further cleanup to VectorPap Lőrinc2016-12-061-56/+63
| | |
* | | Changed >> to >>> in Vector to unify stylePap Lőrinc2016-12-061-118/+118
| | | | | | | | | | | | Unified, since indices are always positive and unsigned shift was already used in other places
* | | Applied suggestions to Vector cleanupPap Lőrinc2016-12-061-179/+161
| | |
* | | Deleted leftover code-comments from VectorPap Lőrinc2016-12-061-93/+20
| | |
* | | Deleted leftover debug method from VectorPap Lőrinc2016-12-061-38/+0
| | |
* | | Unified masks in VectorPap Lőrinc2016-12-061-31/+31
| | |
* | | Removed redundant casts from VectorPap Lőrinc2016-12-061-29/+29
|/ /
* | Merge pull request #5537 from paplorinc/hashTableIndexJason Zaugg2016-11-301-59/+24
|\ \ | | | | | | Optimized HashTable.index
| * | Optimized HashTable.indexPap Lőrinc2016-11-241-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (`ops/s`, smaller is better) `Before (9c5d3f8)`: ```scala [info] # Run complete. Total time: 00:08:15 [info] [info] Benchmark (size) Mode Cnt Score Error Units [info] s.c.immutable.VectorMapBenchmark.groupBy 10 avgt 20 645.594 ± 9.435 ns/op [info] s.c.immutable.VectorMapBenchmark.groupBy 100 avgt 20 2084.216 ± 37.814 ns/op [info] s.c.immutable.VectorMapBenchmark.groupBy 1000 avgt 20 19878.481 ± 262.404 ns/op [info] s.c.mutable.HashMapBenchmark.get 10 avgt 20 689.941 ± 5.850 ns/op [info] s.c.mutable.HashMapBenchmark.get 100 avgt 20 7357.330 ± 45.956 ns/op [info] s.c.mutable.HashMapBenchmark.get 1000 avgt 20 95767.200 ± 1550.771 ns/op [info] s.c.mutable.HashMapBenchmark.getOrElseUpdate 10 avgt 20 509.181 ± 2.683 ns/op [info] s.c.mutable.HashMapBenchmark.getOrElseUpdate 100 avgt 20 5563.301 ± 32.335 ns/op [info] s.c.mutable.HashMapBenchmark.getOrElseUpdate 1000 avgt 20 71965.365 ± 1809.738 ns/op [info] s.c.mutable.HashMapBenchmark.put 10 avgt 20 247.270 ± 3.972 ns/op [info] s.c.mutable.HashMapBenchmark.put 100 avgt 20 5646.185 ± 106.172 ns/op [info] s.c.mutable.HashMapBenchmark.put 1000 avgt 20 81303.663 ± 954.938 ns/op ``` `Changed modulo to bitwise and in hash calculation (4c729fe)`: ```scala [info] Benchmark (size) Mode Cnt Score Error Units [info] s.c.immutable.VectorMapBenchmark.groupBy 10 avgt 20 631.291 ± 9.269 ns/op [info] s.c.immutable.VectorMapBenchmark.groupBy 100 avgt 20 2077.885 ± 59.737 ns/op [info] s.c.immutable.VectorMapBenchmark.groupBy 1000 avgt 20 15458.278 ± 317.347 ns/op [info] s.c.mutable.HashMapBenchmark.get 10 avgt 20 678.013 ± 4.453 ns/op [info] s.c.mutable.HashMapBenchmark.get 100 avgt 20 7258.522 ± 76.088 ns/op [info] s.c.mutable.HashMapBenchmark.get 1000 avgt 20 94748.845 ± 1226.120 ns/op [info] s.c.mutable.HashMapBenchmark.getOrElseUpdate 10 avgt 20 498.042 ± 5.006 ns/op [info] s.c.mutable.HashMapBenchmark.getOrElseUpdate 100 avgt 20 5243.154 ± 110.372 ns/op [info] s.c.mutable.HashMapBenchmark.getOrElseUpdate 1000 avgt 20 68194.752 ± 655.436 ns/op [info] s.c.mutable.HashMapBenchmark.put 10 avgt 20 257.275 ± 1.411 ns/op [info] s.c.mutable.HashMapBenchmark.put 100 avgt 20 5318.532 ± 152.923 ns/op [info] s.c.mutable.HashMapBenchmark.put 1000 avgt 20 79607.160 ± 651.779 ns/op ``` `Optimized HashTable.index (6cc1504)`: ```scala [info] Benchmark (size) Mode Cnt Score Error Units [info] s.c.immutable.VectorMapBenchmark.groupBy 10 avgt 20 616.164 ± 4.712 ns/op [info] s.c.immutable.VectorMapBenchmark.groupBy 100 avgt 20 2034.447 ± 14.495 ns/op [info] s.c.immutable.VectorMapBenchmark.groupBy 1000 avgt 20 14712.164 ± 119.983 ns/op [info] s.c.mutable.HashMapBenchmark.get 10 avgt 20 679.046 ± 6.872 ns/op [info] s.c.mutable.HashMapBenchmark.get 100 avgt 20 7242.097 ± 41.244 ns/op [info] s.c.mutable.HashMapBenchmark.get 1000 avgt 20 95342.919 ± 1521.328 ns/op [info] s.c.mutable.HashMapBenchmark.getOrElseUpdate 10 avgt 20 488.034 ± 4.554 ns/op [info] s.c.mutable.HashMapBenchmark.getOrElseUpdate 100 avgt 20 4883.123 ± 59.268 ns/op [info] s.c.mutable.HashMapBenchmark.getOrElseUpdate 1000 avgt 20 65174.034 ± 496.759 ns/op [info] s.c.mutable.HashMapBenchmark.put 10 avgt 20 267.983 ± 1.797 ns/op [info] s.c.mutable.HashMapBenchmark.put 100 avgt 20 5097.351 ± 104.538 ns/op [info] s.c.mutable.HashMapBenchmark.put 1000 avgt 20 78772.540 ± 543.935 ns/op ``` Summary, i.e. the effect of this PR, according to the benchmarks: * `groupBy` has a `~35%` speedup * `get` didn't change * `getOrElseUpdate` has a `~10%` speedup * `put` has a `~3%` speedup Note: caching the `exponent` to a local private field (`Byte` or `Int`) didn't have any performance advantage (only a minor slowdown was measured, possibly because it's accessed via an interface now)
| * | Changed modulo to bitwise AND in hash calculationPap Lőrinc2016-11-231-52/+17
| | |
* | | Better inliner support for 2.12 trait encodingLukas Rytz2016-11-252-2/+2
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some changes to the trait encoding came late in the 2.12 cycle, and the inliner was not adapted to support it in the best possible way. In 2.12.0 concrete trait methods are encoded as interface T { default int m() { return 1 } static int m$(T $this) { <invokespecial $this.m()> } } class C implements T { public int m() { return T.m$(this) } } If a trait method is selected for inlining, the 2.12.0 inliner would copy its body into the static super accessor `T.m$`, and from there into the mixin forwarder `C.m`. This commit special-cases the inliner: - We don't inline into static super accessors and mixin forwarders. - Insted, when inlining an invocation of a mixin forwarder, the inliner also follows through the two forwarders and inlines the trait method body. There was a difficulty implementing this: inlining the static static super accessor would copy an `invokespecial` instruction into a different classfile, which is not legal / may change semantics. That `invokespecial` is supposed to disappear when inlining the actual default method body. However, this last step may fail, for example because the trait method body itself contains instructions that are not legal in a different classfile. It is very difficult to perform all necessary checks ahead of time. So instead, this commit implements the ability to speculatively inline a callsite and roll back if necessary. The commit also cleans up the implementation of inliner warnings a little. The previous code would always emit a warning when a method annotated `@inline` was not picked by the heuristics - this was a problem when the callsite in the static super accessor was no longer chosen.
* | Changed HashMap.getOrElseUpdate to only calculate the index oncePap Lőrinc2016-11-181-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes https://issues.scala-lang.org/browse/SI-10049 Since `groupBy` uses this method extensively and suffered a measurable slowdown in `2.12.0`, this modification restores (and exceeds) its original speed. --- included benchmarks: (`ns/op` → smaller is better) `before (2.12.0):` ```java Benchmark (size) Mode Cnt Score Error Units s.c.immutable.VectorMapBenchmark.groupBy 10 avgt 20 865.693 ± 7.869 ns/op s.c.immutable.VectorMapBenchmark.groupBy 100 avgt 20 3095.657 ± 56.438 ns/op s.c.immutable.VectorMapBenchmark.groupBy 1000 avgt 20 28247.005 ± 470.513 ns/op s.c.mutable.HashMapBenchmark.get 10 avgt 20 679.448 ± 11.809 ns/op s.c.mutable.HashMapBenchmark.get 100 avgt 20 7240.178 ± 61.734 ns/op s.c.mutable.HashMapBenchmark.get 1000 avgt 20 95725.127 ± 2373.458 ns/op s.c.mutable.HashMapBenchmark.getOrElseUpdate 10 avgt 20 836.561 ± 20.085 ns/op s.c.mutable.HashMapBenchmark.getOrElseUpdate 100 avgt 20 7891.368 ± 56.808 ns/op s.c.mutable.HashMapBenchmark.getOrElseUpdate 1000 avgt 20 97478.629 ± 1782.497 ns/op s.c.mutable.HashMapBenchmark.put 10 avgt 20 243.422 ± 2.915 ns/op s.c.mutable.HashMapBenchmark.put 100 avgt 20 5810.927 ± 60.054 ns/op s.c.mutable.HashMapBenchmark.put 1000 avgt 20 82175.539 ± 1690.296 ns/op ``` `after:` ```java Benchmark (size) Mode Cnt Score Error Units s.c.immutable.VectorMapBenchmark.groupBy 10 avgt 20 627.007 ± 9.718 ns/op s.c.immutable.VectorMapBenchmark.groupBy 100 avgt 20 2086.955 ± 19.042 ns/op s.c.immutable.VectorMapBenchmark.groupBy 1000 avgt 20 19515.234 ± 173.647 ns/op s.c.mutable.HashMapBenchmark.get 10 avgt 20 683.977 ± 11.843 ns/op s.c.mutable.HashMapBenchmark.get 100 avgt 20 7345.675 ± 41.092 ns/op s.c.mutable.HashMapBenchmark.get 1000 avgt 20 95085.926 ± 1702.997 ns/op s.c.mutable.HashMapBenchmark.getOrElseUpdate 10 avgt 20 503.208 ± 2.643 ns/op s.c.mutable.HashMapBenchmark.getOrElseUpdate 100 avgt 20 5526.483 ± 28.262 ns/op s.c.mutable.HashMapBenchmark.getOrElseUpdate 1000 avgt 20 69265.900 ± 674.958 ns/op s.c.mutable.HashMapBenchmark.put 10 avgt 20 252.481 ± 7.597 ns/op s.c.mutable.HashMapBenchmark.put 100 avgt 20 5708.034 ± 110.360 ns/op s.c.mutable.HashMapBenchmark.put 1000 avgt 20 82051.378 ± 1432.009 ns/op ``` i.e. for the given benchmark conditions `~40%` faster `groupBy` and `getOrElseUpdate`
* | Merge pull request #5481 from som-snytt/issue/10007-processLukas Rytz2016-11-183-24/+28
|\ \ | | | | | | SI-10007 sys.process thread sync
| * | SI-10007 sys.process thread syncSom Snytt2016-11-173-24/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A previous change to replace `SyncVar.set` with `SyncVar.put` breaks things. This commit tweaks the thread synchronizing in `sys.process` to actually use `SyncVar` to sync and pass a var. Joining the thread about to exit is superfluous. A result is put exactly once, and consumers use non-destructive `get`. Note that as usual, avoid kicking off threads in a static context, since class loading cycles are somewhat dicier with 2.12 lambdas. In particular, REPL is a static context by default. SI-10007 Clarify deprecation message The message on `set` was self-fulfilling, as it didn't hint that `put` has different semantics. So explain why `put` helps avoid errors instead of creating them. SI-10007 Always set exit value Always put a value to exit code, defaulting to None. Also clean up around tuple change to unfortunately named Future.apply. Very hard to follow those types. Date command pollutes output, so tweak test.
* | | Revert "SI-9750 isJavaAtLeast(Int)"Jason Zaugg2016-11-161-6/+0
| | | | | | | | | | | | | | | | | | This reverts commit 656162bb48fbbd703790a2c94d4563e40ddfdfc2. Adding new APIs is not possible until a major release.
* | | Restore binary compatiblity with 2.12.0Jason Zaugg2016-11-161-3/+3
| |/ |/| | | | | | | | | | | - Revert a typo fix to a non-private method - Whitelist changes to internals of runtime reflection that are not part of the API and should only be referenced from within scala-reflect.jar itself.
* | Typo and spelling correctionsJanek Bogucki2016-11-1145-58/+57
| |
* | Merge pull request #5303 from xuwei-k/isNaN-boxingJason Zaugg2016-11-111-5/+5
|\ \ | | | | | | avoid boxing
| * | avoid boxingxuwei-k2016-10-281-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | scala.runtime.Rich{Double, Float} has `isNaN` and these are value class. Also java.lang.{Double, Float} has `isNaN`. - https://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#isNaN-- - https://docs.oracle.com/javase/8/docs/api/java/lang/Float.html#isNaN-- We can't call `RichDouble#isNaN` because `implicit def double2Double(x: Double): java.lang.Double` is higher priority than `implicit def doubleWrapper(x: Double): RichDouble` ``` $ scala -version Scala code runner version 2.11.8 -- Copyright 2002-2016, LAMP/EPFL $ scala -Xprint:jvm -e "1.0.isNaN" [[syntax trees at end of jvm]] // scalacmd616162202928036892.scala package <empty> { object Main extends Object { def main(args: Array[String]): Unit = { new <$anon: Object>(); () }; def <init>(): Main.type = { Main.super.<init>(); () } }; final class anon$1 extends Object { def <init>(): <$anon: Object> = { anon$1.super.<init>(); scala.this.Predef.double2Double(1.0).isNaN(); () } } } ```
* | | Merge pull request #5335 from rumoku/SI-9888Jason Zaugg2016-11-111-0/+1
|\ \ \ | | | | | | | | SI-9888. Prevent OOM on ParRange. Improve toString.
| * | | SI-9888. Prevent OOM on ParRange. Improve toString.Vladimir Glushak2016-10-021-0/+1
| | | |
* | | | Merge pull request #5516 from Ichoran/non-slow-vector-twelveJason Zaugg2016-11-115-10/+8
|\ \ \ \ | | | | | | | | | | Improved runtime speed for Vector, restoring previous performance.
| * | | | Manually inlined all other instances of Platform.arraycopy to System.arraycopyRex Kerr2016-11-094-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | to avoid the same kind of slowdowns that Vector was experiencing due to the less aggressive inlining by scalac.
| * | | | Improved runtime speed for Vector, restoring previous performance.Rex Kerr2016-11-091-5/+4
| | |_|/ | |/| | | | | | | | | | | | | | | | | | All calls to Platform.arraycopy were rewritten as java.lang.System.arraycopy to reduce the work that the JIT compiler has to do to produce optimized bytecode that avoids zeroing just-allocated arrays that are about to be copied over. (Tested with -XX:-ReduceBulkZeroing as suggested by retronym.)
* | | | Merge pull request #5507 from viktorklang/wip-SI-10034-√Jason Zaugg2016-11-101-1/+1
|\ \ \ \ | | | | | | | | | | SI-10034: Regression: Make Future.failed(e).failed turn into a success instead of failure
| * | | | Regression: Make Future.failed(e).failed turn into a success instead of failureViktor Klang2016-11-081-1/+1
| |/ / /
* | | | Merge commit 'b9a16c4' into 2.12.xJason Zaugg2016-11-081-13/+10
|\ \ \ \ | |/ / / |/| | |
| * | | Merge pull request #5378 from som-snytt/issue/9913Seth Tisue2016-10-261-13/+10
| |\ \ \ | | | | | | | | | | SI-9913 Lead span iterator finishes at state -1
| | * | | SI-9913 Tighten bolts on span iteratorSom Snytt2016-09-061-13/+10
| | | | | | | | | | | | | | | | | | | | | | | | | Extra privacy, and the tricky state transition is made more tabular.
| | * | | SI-9913 Lead span iterator finishes at state -1Som Snytt2016-09-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Even if no elements fail the predicate (so that the trailing iterator is empty).
* | | | | Merge pull request #5373 from TimWSpence/2.12.xSeth Tisue2016-10-311-3/+3
|\ \ \ \ \ | |_|_|_|/ |/| | | | SI-9909: corrected stream example so it does not give forward reference
| * | | | SI-9909: corrected stream example so it does not give forward referenceTim Spence2016-10-211-3/+3
| | | | | | | | | | | | | | | | | | | | error
* | | | | Merge pull request #5276 from som-snytt/issue/9750Seth Tisue2016-10-261-17/+49
|\ \ \ \ \ | | | | | | | | | | | | SI-9750 scala.util.Properties.isJavaAtLeast works with JDK9
| * | | | | SI-9750 Spec check major.minor.securitySom Snytt2016-07-211-21/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't assume spec is just major, but allow arbitrary version number for both spec value and user value to check. Only the first three dot-separated fields are considered, after skipping optional leading value "1" in legacy format. Minimal validity checks of user arg are applied. Leading three fields, if present, must be number values, but subsequent fields are ignored. Note that a version number is not a version string, which optionally includes pre and build info, `9-ea+109`.
| * | | | | SI-9750 isJavaAtLeast(Int)Som Snytt2016-07-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A good opportunity to simplify the API. Versions are strings, but a spec version is just a number.
| * | | | | SI-9750 Tweak tests for what is a numberSom Snytt2016-07-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Leaves the error string as is, but adds test to show how it looks. Java calls it a version number. `Not a version: 1.9`. Don't strip `1.` prefix recursively. (That was Snytt's fault.)
| * | | | | SI-9750 scala.util.Properties.isJavaAtLeast works with JDK9Pavel Petlinsky2016-07-131-11/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The utility method compares javaSpecVersion, which has the form "1.8" previously and "9" going forward. The method accepts "1.n" for n < 9. More correctly, the string argument should be a single number. Supports JEP-223.
* | | | | | assorted typo fixes, cleanup, updating of commentsSeth Tisue2016-10-244-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | just in time for Halloween. "boostrap" is definitely the most adorable typo evah -- and one of the most common, too. but we don't want to scare anybody.
* | | | | | Merge pull request #5451 from lifuhuang/patch-1Lukas Rytz2016-10-211-3/+3
|\ \ \ \ \ \ | | | | | | | | | | | | | | Replace deprecated conforms
| * | | | | | Replace deprecated conformsLifu Huang2016-10-091-3/+3
| | | | | | | | | | | | | | | | | | | | | Replace deprecated conforms with identity.
* | | | | | | Merge pull request #5371 from chrisokasaki/issue/9906Seth Tisue2016-10-201-0/+19
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | SI-9906: override ListBuffer.last/lastOption to run in O(1) time
| * | | | | | | SI-9906: override ListBuffer.last/lastOption to run in O(1) timechrisokasaki2016-08-301-0/+19
| | |_|/ / / / | |/| | | | | | | | | | | | | | | | | | | Also update scaladocs for those two methods.
* | | | | | | Merge pull request #5400 from sjrd/rewrite-traversablelike-stringprefixSeth Tisue2016-10-201-12/+59
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Rewrite TraversableLike.stringPrefix not to blow up code size in Scala.js.
| * | | | | | | Rewrite TraversableLike.stringPrefix not to blow up code size in Scala.js.Sébastien Doeraene2016-09-151-12/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The commit 30876fe2dd8cbe657a6cad6b11bbc34f10c29b36 changed `TraversableLike.stringPrefix` to report nicer results for inner classes and method-local classes. The changes included calls to `String.split()`, `Character.isDigit()` and `Character.isUpperCase()`. This was particularly bad for Scala.js, because those methods bring with them huge parts of the JDK (the `java.util.regex.*` implementation on the one hand, and the Unicode database on the other hand), which increased generated code size by 6 KB after minimification and gzip for an application that does not otherwise use those methods. This sudden increase is tracked in the Scala.js bug tracker at https://github.com/scala-js/scala-js/issues/2591. This commit rewrites `TraversableLike.stringPrefix` in a very imperative way, without resorting to those methods. The behavior is (mostly) preserved. There can be different results when `getClass().getName()` contains non-ASCII lowercase letters and/or digits. Those will now be recognized as user-defined instead of likely compiler-synthesized (which is a progression). There still are false positives for ASCII lowercase letters, which cause the `stringPrefix` to be empty (as before). Since the new implementation is imperative anyway, at least I made it not allocate anything but the result `String` in the common case where the result does not contain any `.`.