| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| | |
SD-48 limit the lenght of inlined local variable names
|
| |
| |
| |
| |
| |
| | |
When inlining local variables, the names are prefixed with the callee
method name. In long chains of inlining, these names can grow
indefinitely. This commits introduces a limit.
|
|\ \
| | |
| | | |
SD-186 Fix positions in trait method bytecode
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Concrete, non private methods in traits are translated into a static
method with an explicit `$this` parameter. After this translation,
the references to `$this` (subistuted for `this` in user written code)
where being positioned at the position of the method, which makes
debugging unpleasant.
This commit leaves the `Ident($this)` trees unpositioned. This is
analagous to what we do in the body of extension methods, which
is the other user of `ThisSubstitutor`.
It would be more correct to copy the position of each `This`
tree over to the substituted tree. That would let us set a breakpoint
on a line that _only_ contained `this`. But in 99% of cases users
won't be able to spot the difference, so I've opted for the tried
and tested approach here.
|
|\ \ \
| | | |
| | | | |
SI-9827 MatchIterator advances itself
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
To avoid caveats about calling `next` (or `hasNext`) before
using `MatchData` methods on `MatchIterator`, just do it
internally as necessary.
Note `MatchIterator` behavior in the docs.
Added tests showing what people cried about.
|
| |_|/
|/| |
| | |
| | | |
This exposes a new API to the BufferedIterator trait. It will return the next element of an iterator as an Option. The return will be Some(value) if there is a next value, and None if there is not a next element.
|
|\ \ \
| |_|/
|/| | |
Avoid triple-quoting triple quotes in printer
|
| | |
| | |
| | |
| | |
| | | |
Since octal escape is deprecated, use unicode escape
for string representation of constants.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
To quote a triple quote, only quote one quote.
Refactors the code for legibility.
Adds test for other inline cruft like control chars.
|
| | |
| | |
| | |
| | |
| | |
| | | |
The boolean test for triples was inadvertently flipped.
Adds test for pretty printed multiline strings
|
| |/
|/|
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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.
|
|\
| |
| | |
SI-9390 Emit local defs that don't capture this as static
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|\|
| |
| | |
Lambda impl methods static and more stably named
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|\ \
| | |
| | | |
Fix comparisons involving NaN
|
| | |
| | |
| | |
| | |
| | | |
Floating point comparisons involving NaN should always return false,
except for !=. Fixes a regression introduced by #4963.
|
|\ \ \
| |/ /
|/| | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| |/
|/|
| |
| |
| |
| |
| | |
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.
|
|\ \
| | |
| | | |
Improvements to deprecations related to `since` parameter
|
| | | |
|
|\ \ \
| |/ /
|/| | |
SI-9382 Privatize enhanced x in Tuple2Zipped.Ops
|
| | |
| | |
| | |
| | |
| | | |
Consolated JUnit tests and heeded comment about private def and
code beauty.
|
|\ \ \
| | | |
| | | | |
SI-2712 Add support for partial unification of type constructors
|
| |/ / |
|
|\ \ \
| | | |
| | | | |
Debug flag to print a summary of the inliner's work
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
|\ \ \
| | | |
| | | | |
Fully qualify types in REPL generated code
|
| | | | |
|
|/ / /
| | |
| | |
| | | |
Keep -Yopt-inline-heuristics and -Yopt-trace unchanged
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| | |
Also adds a mising phase travel in the backend. A comment already
points out why it's necessary, but it was actually forgotten.
|
|\ \
| | |
| | | |
Clean up JUnit tests, make sure they pass without bootstrap [ci: last-only]
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|