summaryrefslogtreecommitdiff
path: root/src/library
Commit message (Collapse)AuthorAgeFilesLines
* 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 `.`.
* | | | | Merge pull request #5463 from adriaanm/merge-2.11-to-2.12Seth Tisue2016-10-203-9/+10
|\ \ \ \ \ | | | | | | | | | | | | Merge 2.11 to 2.12
| * \ \ \ \ Merge 2.11.x into 2.12.x, including #5239, #5240Adriaan Moors2016-10-181-0/+1
| |\ \ \ \ \
| | * \ \ \ \ Merge pull request #5239 from martijnhoekstra/doc_capitalizeAdriaan Moors2016-10-181-0/+1
| | |\ \ \ \ \ | | | | | | | | | | | | | | | | Doc: capitalize doesn't handle non-BMP characters
| | | * | | | | doc: capitalize only works on BMP charactersMartijn Hoekstra2016-06-211-0/+1
| | | | | | | |
| * | | | | | | Merge 2.11.x into 2.12.xAdriaan Moors2016-10-182-9/+9
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Including PRs #5199, #5405
| | * | | | | | In ProcessBuilder docs, replace .lines w/ .lineStreamPaul Kernfeld2016-09-162-9/+9
| | |/ / / / / | | | | | | | | | | | | | | | | | | | | | ProcessBuilder.lines is deprecated
| | * | | | | SI-9737 [no-merge] Backport stringOf ParIterableNicolas Stucki2016-06-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cherry-picked c5f3d3f286ee5c26c8ddcf10f6878058e8f7e040 Edited comment: in stringOf, let GenIterable subsume both Iterable and ParIterable. This change is required for Scala.js compatibility as it does not support parallel collections. Conflicts: src/library/scala/runtime/ScalaRunTime.scala
* | | | | | | Fix typo in GenTraversableLikeBoris Korogvich2016-10-201-1/+1
|/ / / / / /
* | | | | | Merge remote-tracking branch 'origin/2.12.0' into merge/2.12.0-to-2.12.xJason Zaugg2016-10-144-10/+32
|\ \ \ \ \ \ | |_|_|_|/ / |/| | | | |
| * | | | | Explicit SerialVersionUID for all ClassTags / ManifestsLukas Rytz2016-09-304-10/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Looking at the class hierarchy around ClassTag and Manifest, the only class that had a serialVersionUID is AnyValManifest, where the hierarchy is something like: trait ClassTag // extends Serializable |- class GenericClassTag |- trait Manifest |- class ClassTypeManifest |- class SingletonTypeManifest |- ... |- abstract class AnyValManifest // has SerialVersionUID |- class DoubleManifest |- ... Note that AnyValManifest is an abstract class, so the SerialVersionUID annotation does not help there. This commit adds explicit SerialVersionUID annotations to (hopefully) all subclasses of ClassTag, to make sure they are stable under compatible changes (such as changing -Xmixin-force-forwarders).
* | | | | | Merge pull request #5416 from SethTisue/merge-2.12.0-to-2.12.x-sep-24Seth Tisue2016-10-053-25/+24
|\| | | | | | | | | | | | | | | | | merge 2.12.0 onto 2.12.x [ci: last-only]
| * | | | | Merge pull request #5430 from adriaanm/dev235Adriaan Moors2016-09-291-9/+10
| |\ \ \ \ \ | | | | | | | | | | | | | | Emit local module like lazy val
| | * | | | | Make some name suffixes constantsAdriaan Moors2016-09-281-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's still a lot of duplication, as well as plenty of opportunities for constant folding / simplification.
| * | | | | | don't deprecate Either.left and Either.right yetSeth Tisue2016-09-281-15/+13
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for two reasons: * to facilitate warning-free cross-compilation between Scala 2.11 and 2.12 * because it's not clear that .swap is a good replacement for .left Either.right seems almost certain to be deprecated in 2.13. Either.left's future is uncertain; see discussion (and links to additional discussions) at https://github.com/scala/scala/pull/5135
| * | / / / Including Lightbend in `-version` message.Adriaan Moors2016-09-271-1/+1
| | |/ / / | |/| | | | | | | | | | | | | Also consistently use "LAMP/EPFL" and not "EPFL LAMP".
* / | | | SI-9936 SeqLike.indexWhere starts at zeroSom Snytt2016-09-261-1/+1
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This follows the Scaladoc, and makes ``` "abcdef".indexOf('c', -1) ``` work like ``` "abcdef".toVector.indexOf('c', -1) ```
* | | | Merge pull request #5368 from retronym/ticket/SD-208Adriaan Moors2016-09-062-32/+10
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | SD-208 Restore 2.11 names for arrayOps implicits Fix scala/scala-dev#208
| * | | | SD-208 Restore 2.11 names for arrayOps implicitsJason Zaugg2016-08-312-32/+10
| | |/ / | |/| |
* | | | More elegant holders for local lazy vals.Adriaan Moors2016-09-021-20/+125
| | | |
* | | | Merge pull request #5294 from adriaanm/fields-laziesAdriaan Moors2016-09-011-0/+52
|\ \ \ \ | |/ / / |/| | | Fields: expand lazy vals during fields, like modules
| * | | Fields does bitmaps & synch for lazy vals & modulesAdriaan Moors2016-08-291-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Essentially, we fuse mixin and lazyvals into the fields phase. With fields mixing in trait members into subclasses, we have all info needed to compute bitmaps, and thus we can synthesize the synchronisation logic as well. By doing this before erasure we get better signatures, and before specialized means specialized lazy vals work now. Mixins is now almost reduced to its essence: implementing super accessors and forwarders. It still synthesizes accessors for param accessors and early init trait vals. Concretely, trait lazy vals are mixed into subclasses with the needed synchronization logic in place, as do lazy vals in classes and methods. Similarly, modules are initialized using double checked locking. Since the code to initialize a module is short, we do not emit compute methods for modules (anymore). For simplicity, local lazy vals do not get a compute method either. The strange corner case of constant-typed final lazy vals is resolved in favor of laziness, by no longer assigning a constant type to a lazy val (see widenIfNecessary in namers). If you explicitly ask for something lazy, you get laziness; with the constant-typedness implicit, it yields to the conflicting `lazy` modifier because it is explicit. Co-Authored-By: Lukas Rytz <lukas@lightbend.com> Fixes scala/scala-dev#133 Inspired by dotc, desugar a local `lazy val x = rhs` into ``` val x$lzy = new scala.runtime.LazyInt() def x(): Int = { x$lzy.synchronized { if (!x$lzy.initialized) { x$lzy.initialized = true x$lzy.value = rhs } x$lzy.value } } ``` Note that the 2.11 decoding (into a local variable and a bitmap) also creates boxes for local lazy vals, in fact two for each lazy val: ``` def f = { lazy val x = 0 x } ``` desugars to ``` public int f() { IntRef x$lzy = IntRef.zero(); VolatileByteRef bitmap$0 = VolatileByteRef.create((byte)0); return this.x$1(x$lzy, bitmap$0); } private final int x$lzycompute$1(IntRef x$lzy$1, VolatileByteRef bitmap$0$1) { C c = this; synchronized (c) { if ((byte)(bitmap$0$1.elem & 1) == 0) { x$lzy$1.elem = 0; bitmap$0$1.elem = (byte)(bitmap$0$1.elem | 1); } return x$lzy$1.elem; } } private final int x$1(IntRef x$lzy$1, VolatileByteRef bitmap$0$1) { return (byte)(bitmap$0$1.elem & 1) == 0 ? this.x$lzycompute$1(x$lzy$1, bitmap$0$1) : x$lzy$1.elem; } ``` An additional problem with the above encoding is that the `lzycompute` method synchronizes on `this`. In connection with the new lambda encoding that no longer generates anonymous classes, captured lazy vals no longer synchronize on the lambda object. The new encoding solves this problem (scala/scala-dev#133) by synchronizing on the lazy holder. Currently, we don't exploit the fact that the initialized field is `@volatile`, because it's not clear the performance is needed for local lazy vals (as they are not contended, and as soon as the VM warms up, biased locking should deal with that) Note, be very very careful when moving to double-checked locking, as this needs a different variation than the one we use for class-member lazy vals. A read of a volatile field of a class does not necessarily impart any knowledge about a "subsequent" read of another non-volatile field of the same object. A pair of volatile reads and write can be used to implement a lock, but it's not clear if the complexity is worth an unproven performance gain. (Once the performance gain is proven, let's change the encoding.) - don't explicitly init bitmap in bytecode - must apply method to () explicitly after uncurry
* | | | Merge pull request #5364 from retronym/topic/instanceof-perf-2Adriaan Moors2016-08-303-10/+21
|\ \ \ \ | | | | | | | | | | SI-9823 Collections perf: favor virtual call over instanceof
| * | | | SI-9823 Collections perf: favor virtual call over instanceofJason Zaugg2016-08-303-10/+21
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This avoids concurrent usages of collections in NUMA architectures from falling of a performance cliff due to an implementation detail of interface instanceof checks in HotSpot JVM. The VM contains a one element cache in the metadata of each class to record the most recent successful test for a interface. For example: classOf[Serializable].isAssignableFrom(classOf[Some[_]]) Would, in addition to returning `true`, set: classOf[Some[_]]._secondary_super_cache = classOf[Serializable] This is done to hide the fact that interface tests are O(N), where N is the number of inherited interfaces. This scheme is discussed in "Fast Subtype Checking for the HotSpot JVM" (Click, Rose) [1] However, if this cache repeatedly misses, not only are we exposed to the linear search of the secondary super type array, but we are also required to write back to the cache. If other cores are operating on the same cache line, this can lead to a significant slowdown ("cache thrashing"). This effect will by most (or only?) visible on multi socket machines. The pathological case is: scala> Iterator.continually(List(classOf[Product], classOf[Serializable])).flatten.take(100).map(intf => intf.isAssignableFrom(classOf[Some[_]])).count(x => x) res19: Int = 100 Which, if run on a multi-socket machine, should be much slower than: scala> (Iterator.continually(classOf[Product]).take(50) ++ Iterator.continually(classOf[Serializable]).take(50)).map(intf => intf.isAssignableFrom(classOf[Some[_]])).count(x => x) res20: Int = 100 This commit avoids a interface test in a hot path in the collections by instead using virtual dispatch to differentiate between IndexedSeqLike and other collections. HotSpot will still use some shared bookkeeping ("inline cache" [2]) at the callsites of this method, but these stabilize in the megamorphic usage and no longer force expensive cache line synchronization. [1] https://www.researchgate.net/publication/221552851_Fast_subtype_checking_in_the_HotSpot_JVM [2] https://wiki.openjdk.java.net/display/HotSpot/PerformanceTechniques
* / / / SI-6967 Primitive ClassTag.unapply is removedSom Snytt2016-08-291-15/+0
|/ / / | | | | | | | | | | | | Follow-up to remove the overloads, which is source compatible, in favor of unapply(Any).
* | | SD-128 fix override checks for default methodsLukas Rytz2016-08-121-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The check for inheriting two conflicting members was wrong for default methods, leading to a missing error message. We were also not issuing "needs `override' modifier" when overriding a default method. Removes two methods: - `isDeferredOrJavaDefault` had a single use that is removed in this commit. - `isDeferredNotJavaDefault` is redundant with `isDeferred`, because no default method has the `DEFERRED` flag: - For symbols originating in the classfile parser this was the case from day one: default methods don't receive the `DEFERRED` flag. Only abstract interface methods do, as they have the `JAVA_ACC_ABSTRACT` flag in bytecode, which the classfile parser translates to `DEFERRED`. - For symbols created by the Java source parser, we don't add the `DEFERRED` to default methods anymore since 373db1e. Fixes scala/scala-dev#128
* | | Merge pull request #5321 from retronym/topic/lock-down-deserializeAdriaan Moors2016-08-122-24/+25
|\ \ \ | | | | | | | | SD-193 Lock down lambda deserialization
| * | | Cleanups after code reviewJason Zaugg2016-08-102-26/+5
| | | | | | | | | | | | | | | | | | | | - Remove unused references to "addTargetMethods" - Require that `targetMethodMap` is provided
| * | | SD-193 Lock down lambda deserializationJason Zaugg2016-08-082-9/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old design allowed a forged `SerializedLambda` to be deserialized into a lambda that could call any private method in the host class. This commit passes through the list of all lambda impl methods to the bootstrap method and verifies that you are deserializing one of these. The new test case shows that a forged lambda can no longer call the private method, and that the new encoding is okay with a large number of lambdas in a file. We already have method handle constants in the constant pool to support the invokedynamic through LambdaMetafactory, so the only additional cost will be referring to these in the boostrap args for `LambdaDeserialize`, 2 bytes per lambda. I checked this with an example: https://gist.github.com/retronym/e343d211f7536d06f1fef4b499a0a177 Fixes SD-193
* | | | Merge pull request #5323 from szeiger/issue/7838-2Seth Tisue2016-08-123-0/+15
|\ \ \ \ | | | | | | | | | | SI-7838 Document the multi-threading semantics of List and Vector
| * | | | SI-7838 Document the multi-threading semantics of List and VectorStefan Zeiger2016-08-123-0/+15
| | | | | | | | | | | | | | | | | | | | Making them completely thread-safe would be too expensive (in terms of performance of single-threaded use cases).
* | | | | Merge pull request #5306 from szeiger/issue/8576Stefan Zeiger2016-08-121-0/+1
|\ \ \ \ \ | | | | | | | | | | | | SI-8576 Minimal changes for `-Xcheckinit` compatibility
| * | | | | SI-8576 Minimal changes for `-Xcheckinit` compatibilityStefan Zeiger2016-08-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As explained in https://issues.scala-lang.org/browse/SI-8576, I expect serialization compatibility between builds with and without `-Xcheckinit` to be unattainable. This commit contains some minor fixes for issues discovered while running builds with `-Xcheckinit`: - Add `@SerialVersionUID` to `scala.collection.immutable.Vector`, as requested in SI-8576. Note that this does not make `Vector` serialization compatible. - Use lazy initialization for `global` in `PresentationCompilation`. It used to access the uninitialized `self` variable (which seems to be inconsequential in practice and only fails under `-Xcheckinit`). We should consider using `Externalizable` instead of `Serializable` for collections in 2.13 to make collection classes serialization compatible.
* | | | | | Merge pull request #5312 from szeiger/issue/8434-2Stefan Zeiger2016-08-121-1/+5
|\ \ \ \ \ \ | | | | | | | | | | | | | | SI-8434 Make generic Set operations build the same kind of Set
| * | | | | | SI-8434 Make generic Set operations build the same kind of SetStefan Zeiger2016-08-121-1/+5
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When building from a `Set` implementation that was statically seen as a `collection.GenSet` or `collection.Set`, we used to build a default `Set` implementation determined by `GenSetFactory.setCanBuildFrom`. This change modifies `setCanBuildFrom` to determine the correct implementation at runtime by asking the source `Set`’s companion object for the `Builder`. Tests are in `NewBuilderTest.mapPreservesCollectionType`, including lots of disabled tests for which I believe there is no solution under the current collection library design. `Map` suffers from the same problem as `Set`. This *can* be fixed in the same way as for `Set` with some non-trivial changes (see the note in `NewBuilderTest`), so it is probably best left for Scala 2.13.
* | | | | | Merge pull request #5258 from szeiger/issue/9019Stefan Zeiger2016-08-121-6/+15
|\ \ \ \ \ \ | | | | | | | | | | | | | | SI-9019 TraversableLike stringPrefix broken for inner classes
| * | | | | | SI-9019 TraversableLike stringPrefix broken for inner classesRex Kerr2016-08-121-6/+15
| | |_|_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This version preserves outer class and object names but discards any part of the name after a `$` that does not start with an upper-case letter. When an integer literal occurs after a `$`, the prefix up to that point is dropped so that classes defined within methods appear as top-level.