summaryrefslogtreecommitdiff
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #3794 from lrytz/t8625Jason Zaugg2014-05-271-3/+10
|\ | | | | SI-8625 fix unreachability analysis for boolean expressions
| * SI-8625 fix unreachability analysis for boolean expressionsLukas Rytz2014-05-271-3/+10
| |
* | Merge pull request #3782 from retronym/topic/opt-scopeJason Zaugg2014-05-272-12/+19
|\ \ | |/ |/| Compiler optimizations for Scopes, checkDoubleDefs, Namer
| * Optimize enforcement of dependent method type restrictionsJason Zaugg2014-05-261-5/+4
| | | | | | | | | | | | | | - No need to check the result type, as dependent method types are now enabled unconditionally. - This also means we can only need to check methods with two or more parameter lists.
| * Fast path in Namer for methods without defaultsJason Zaugg2014-05-261-3/+8
| | | | | | | | | | | | | | Either direct defaults, or directly inherited. The avoids `addDefaultGetters` in most cases, and the expensive duplication of trees therein.
| * Eliminate some N^2 performance in type checkingJason Zaugg2014-05-261-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Where N is the number of members of the enclosing package. Double definition errors for top level classes/objects are issued elsewhere, as demonstrated by the enclosed test. So we can omit the call to `checkNoDoubleDefs` in this content. We can't omit the call to `addSynthetics` for package class owners (case- and value-class synthetic companions are added here), but we can make the process cheaper by moving the expensive-but-usually-true call to `shouldAdd`. Here's an example of the improvement. % rm -rf /tmp/pkg; (for i in {1..50}; do for j in {1..100}; do echo "package pkg { class A_${i}_${j}___(val a: Int, val b: Int) }"; done; done) > sandbox/A1.scala && time scalac-hash v2.11.0 -Ybackend:GenASM -J-Xmx1G -J-XX:MaxPermSize=400M -d /tmp sandbox/A1.scala; real 0m49.762s user 1m12.376s sys 0m2.371s % rm -rf /tmp/pkg; (for i in {1..50}; do for j in {1..100}; do echo "package pkg { class A_${i}_${j}___(val a: Int, val b: Int) }"; done; done) > sandbox/A1.scala && time qbin/scalac -Ybackend:GenASM -J-Xmx1G -J-XX:MaxPermSize=400M -d /tmp sandbox/A1.scala; real 0m35.662s user 0m58.275s sys 0m2.355s We've still got another source of pathological performance in creating nested scopes that I'll fix in the next commit.
* | SI-8617 Avoid rangepos crash for OptManifest materializerJason Zaugg2014-05-241-1/+1
|/ | | | The tree to create a `NoManifest` was unpositioned.
* Upgrade ASM to 5.0.2Lukas Rytz2014-05-204-18/+20
| | | | | | | | | | | | | This commit is a squashed version of all commits in PR #3747. For future upgrades, consult the README and check the commits in https://github.com/scala/scala/pull/3747/commits There's one bug in ASM 5.0.2 that breaks scalac: http://forge.ow2.org/tracker/?func=detail&aid=317200&group_id=23&atid=100023 This bug is fixed in ASM trunk, the patch has been merged into this commit. A future upgrade of ASM should contain the fix.
* SI-8601 Don't treat newarray as dead codeJason Zaugg2014-05-191-1/+1
| | | | Otherwise we lose the side effect of a `NegativeArraySizeException`.
* SI-8601 Avoid over-eager optimization of LOAD_FIELDJason Zaugg2014-05-192-5/+7
| | | | | | | | | | | | | | | | | | It can NPE or trigger static class initilization, we can't elimiate it without changing semantics. To make sure we don't thwart closure elimination, I've allowed DCE to eliminate a non-static LOAD_FIELD of a member of a closure class. It would be more general to track nullity of the reciever (e.g, `this` or `new Foo` cannot be null), but that would require more infrastructure in this phase. I've added a test for closure inlining based on a a suggestion by @dragos. This actually passes if we remove the (LOAD_FIELD, DROP) peephole optimization for `closelim` altogether. But I chose to adapt that optimization (only allow it for non-static, closure fields), rather then remove it alogether, in the interests of treading lightly.
* SI-8601 Don't treat int/long division, or arraylength, as dead-codeJason Zaugg2014-05-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `{i, l}div` and `{i, l}rem` throw an `ArithmeticException` if the divisor is 0. `arraylength` throws a `NullPointerException` on a null reference. JVM Spec: > The only integer operations that can throw an exception are the > integer divide instructions (idiv and ldiv) and the integer > remainder instructions (irem and lrem), which throw an > ArithmeticException if the divisor is zero. > The Java virtual machine's floating-point operators do not throw > runtime exceptions > If the arrayref is null, the arraylength instruction throws a > NullPointerException. I checked the other primitives in `ICode` to see if anything else should be considered as live code. Pure: // jvm : {i, l, f, d}neg case class Negation(kind: TypeKind) extends Primitive // jvm : if{eq, ne, lt, ge, le, gt}, if{null, nonnull} // if_icmp{eq, ne, lt, ge, le, gt}, if_acmp{eq,ne} case class Test(op: TestOp, kind: TypeKind, zero: Boolean) extends Primitive // jvm : lcmp, {f, d}cmp{l, g} case class Comparison(op: ComparisonOp, kind: TypeKind) extends Primitive Impure: {i, l}{div, rem}, otherwise pure // jvm : {i, l, f, d}{add, sub, mul, div, rem} case class Arithmetic(op: ArithmeticOp, kind: TypeKind) extends Primitive Pure (overflow is silent, NaN.toInt is defined): // jvm : {i, l}{and, or, xor} case class Logical(op: LogicalOp, kind: TypeKind) extends Primitive // jvm : {i, l}{shl, ushl, shr} case class Shift(op: ShiftOp, kind: TypeKind) extends Primitive // jvm : i2{l, f, d}, l2{i, f, d}, f2{i, l, d}, d2{i, l, f}, i2{b, c, s} case class Conversion(src: TypeKind, dst: TypeKind) extends Primitive Impure! May NPE! // jvm : arraylength case class ArrayLength(kind: TypeKind) extends Primitive Pure (we know that StringBuilder.{<init>, append, toString} are pure and `append` is null safe.) // jvm : It should call the appropiate 'append' method on StringBuffer case class StringConcat(el: TypeKind) extends Primitive // jvm: it should create a new StringBuffer case object StartConcat extends Primitive // jvm: convert StringBuffer to a String case object EndConcat extends Primitive
* Revert "SI-8601 Don't treat int/long division, or arraylength, as dead-code"Adriaan Moors2014-05-191-2/+0
| | | | This reverts commit ee611cd76c29fedd416162e482c7ab3f15b831ca.
* Revert "SI-8601 Avoid over-eager optimization of LOAD_FIELD"Adriaan Moors2014-05-192-5/+6
| | | | This reverts commit 0b432f9cd22b6e9770852e5b331a15f0534a312c.
* Revert "SI-8601 Don't treat newarray as dead code"Adriaan Moors2014-05-191-1/+1
| | | | This reverts commit 70b912a87433c9589af33e4f8b33dca39abb66e5.
* SI-8601 Don't treat newarray as dead codeJason Zaugg2014-05-181-1/+1
| | | | Otherwise we lose the side effect of a `NegativeArraySizeException`.
* SI-8601 Avoid over-eager optimization of LOAD_FIELDJason Zaugg2014-05-182-6/+5
| | | | | It can NPE or trigger static class initilization, we can't elimiate it without changing semantics.
* SI-8601 Don't treat int/long division, or arraylength, as dead-codeJason Zaugg2014-05-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `{i, l}div` and `{i, l}rem` throw an `ArithmeticException` if the divisor is 0. `arraylength` throws a `NullPointerException` on a null reference. JVM Spec: > The only integer operations that can throw an exception are the > integer divide instructions (idiv and ldiv) and the integer > remainder instructions (irem and lrem), which throw an > ArithmeticException if the divisor is zero. > The Java virtual machine's floating-point operators do not throw > runtime exceptions > If the arrayref is null, the arraylength instruction throws a > NullPointerException. I checked the other primitives in `ICode` to see if anything else should be considered as live code. Pure: // jvm : {i, l, f, d}neg case class Negation(kind: TypeKind) extends Primitive // jvm : if{eq, ne, lt, ge, le, gt}, if{null, nonnull} // if_icmp{eq, ne, lt, ge, le, gt}, if_acmp{eq,ne} case class Test(op: TestOp, kind: TypeKind, zero: Boolean) extends Primitive // jvm : lcmp, {f, d}cmp{l, g} case class Comparison(op: ComparisonOp, kind: TypeKind) extends Primitive Impure: {i, l}{div, rem}, otherwise pure // jvm : {i, l, f, d}{add, sub, mul, div, rem} case class Arithmetic(op: ArithmeticOp, kind: TypeKind) extends Primitive Pure (overflow is silent, NaN.toInt is defined): // jvm : {i, l}{and, or, xor} case class Logical(op: LogicalOp, kind: TypeKind) extends Primitive // jvm : {i, l}{shl, ushl, shr} case class Shift(op: ShiftOp, kind: TypeKind) extends Primitive // jvm : i2{l, f, d}, l2{i, f, d}, f2{i, l, d}, d2{i, l, f}, i2{b, c, s} case class Conversion(src: TypeKind, dst: TypeKind) extends Primitive Impure! May NPE! // jvm : arraylength case class ArrayLength(kind: TypeKind) extends Primitive Pure (we know that StringBuilder.{<init>, append, toString} are pure and `append` is null safe.) // jvm : It should call the appropiate 'append' method on StringBuffer case class StringConcat(el: TypeKind) extends Primitive // jvm: it should create a new StringBuffer case object StartConcat extends Primitive // jvm: convert StringBuffer to a String case object EndConcat extends Primitive
* Merge pull request #3738 from retronym/ticket/8574Jason Zaugg2014-05-172-1/+2
|\ | | | | SI-8574 Copy @SerialVersionUID, etc, to specialized subclasses
| * SI-8574 Copy @SerialVersionUID, etc, to specialized subclassesJason Zaugg2014-05-162-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | The test case demonstrates that this is important for serialization and for strictfp. (Although the latter is still pretty broken, see SI-7954.) Now that the synthetic subclass of `Tuple2[Int, Int]` also has the `@deprecatedInheritance` annotation, I had to change the spot that issues this warning to be silent after the typer phase. Otherwise, we get two warnings in `run/t3888.scala`. This also remedies double warnings that were incurred in `neg/t6162-inheritance`.
* | SI-8582 emit InnerClasses attribute in GenBCodeLukas Rytz2014-05-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I removed the `-bcode` test since we have a build that passes `-Ybackend:GenBCode` to all tests. Short intro do the [`InnerClass` attribute][1]: - A class needs one `InnerClass` attribute for each of its nested classes - A class needs the `InnerClass` attribute for all (nested) classes that are mentioned in its constant pool The attribute for a nested class `A$B$C` consists of the long name of the outer class `A$B`, the short name of the inner class `C`, and an access flag set describig the visibility. The attribute seems to be used for reflection. [1]: http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.6
* | Fix BeanInfo generation for GenBCodeLukas Rytz2014-05-131-1/+1
| |
* | Allow tracing methods and classes in GenBCodeLukas Rytz2014-05-135-2/+75
| |
* | SI-8578 Avoid another potential fresh name clashJason Zaugg2014-05-111-1/+1
| | | | | | | | | | No test case for this one, but see the preceding commit for the class of bug that I'm trying to avoid.
* | SI-8578 Avoid fresh name clashes under -Ydelambdafy:methodJason Zaugg2014-05-111-1/+1
|/ | | | | It is important to append the fresh 'N' after '$'. Otherwise, we find out the hard way that ("foo$11" + "1") == ("foo$1" + "11").
* Merge pull request #3730 from lrytz/checkinitJason Zaugg2014-05-091-32/+54
|\ | | | | Fix checkinit build
| * Clarify and clean up trait getter / setter generationLukas Rytz2014-05-091-35/+54
| |
| * SI-8570 set the checkinit bit for unit-typed fields of traitsLukas Rytz2014-05-091-3/+6
| | | | | | | | Fix only, refactoring in subsequent commit.
* | Merge origin/master into topic/master-to-2.11.x-2Jason Zaugg2014-05-094-6/+33
|\ \
| * \ Merge pull request #3597 from som-snytt/issue/5905-feature-helpJason Zaugg2014-05-094-6/+33
| |\ \ | | | | | | | | SI-5905 Sanity check -language options
| | * | SI-5905 Restore -language:_Som Snytt2014-03-022-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Underscore means all. -x:c,b,a,_ results in value c,b,a,a,b,c,d,... Currently, -Xprint does not present phases as a closed set of choices; there is ad hoc checking in Global. That would be a nice unification. (You don't know the list of choices until after global is constructed.)
| | * | SI-5905 Sanity check -language optionsSom Snytt2014-02-283-5/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The option names are hardcoded, but checked by a test. There are no hooks to verify options after the compiler is constructed. Introduced a `MultiChoiceSetting` required for the setting creation framework.
* | | | Merge pull request #3719 from retronym/ticket/8546Jason Zaugg2014-05-091-2/+3
|\ \ \ \ | | | | | | | | | | SI-8546 Pattern matcher analysis foiled by over-widening
| * | | | SI-8546 Pattern matcher analysis foiled by over-wideningJason Zaugg2014-05-071-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the enclosed test, the prefix checkable type `ModuleTypeRef(F2.this, C)` was being inadvertently widened to `ModuleTypeRef(F2[?], C)`. This started after some misguided future-proofing in SI-6771 / 3009916. This commit changes the `dealiasWiden` to a `delias`.
* | | | | Merge pull request #3727 from retronym/ticket/8531Jason Zaugg2014-05-091-2/+6
|\ \ \ \ \ | | | | | | | | | | | | SI-8531 Better space efficiency for patmat analysis
| * | | | | SI-8531 Better space efficiency for patmat analysisJason Zaugg2014-05-081-2/+6
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By adding logging to `clause`, I found that the majority of calls provide 0 or 1 elements. In SI-7020 / 69557da55, we changed this method to use a `LinkedHashSet` to have deterministic results for clauses with more elements. But I suspect that this contributes to higher memory usage from the pattern matcher. The enclosed test case, carefully whittled down by @oxbowlakes, used to consume an inordinate amount of memory and time. After this patch, it is back to 2.10.4 performance. I have run `neg/t7020.scala` in a loop and it still is deterministic.
* | | | | Merge commit 'b5392a0' into merge/master-to-2.11.xJason Zaugg2014-05-095-21/+40
|\ \ \ \ \ | | |/ / / | |/| | |
| * | | | Merge pull request #3689 from xeno-by/ticket/8523Jason Zaugg2014-05-081-1/+1
| |\ \ \ \ | | | | | | | | | | | | makes bundles friendly to -Ywarn-dead-code
| | * | | | makes bundles friendly to -Ywarn-dead-codeEugene Burmako2014-04-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apparently, the `new Bundle(???).impl` synthetic tree generated as a macro impl ref for bundles evokes -Ywarn-dead-code warnings. This pull requests changes `???` to `null` in order not to stress out the checker. What's in the argument doesn't actually make any difference anyway.
| * | | | | Merge pull request #3711 from retronym/ticket/8549-2Jason Zaugg2014-05-082-10/+8
| |\ \ \ \ \ | | | | | | | | | | | | | | SI-8549 Serialization: fix regression with @SerialVersionUID / start enforcing backwards compatibility
| | * | | | | SI-8549 Honour the @SerialVersionUID annotatationJason Zaugg2014-05-052-10/+8
| | | |/ / / | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In PR #1673 / 4267444, the annotation `SerialVersionId` was changed from a `StaticAnnotation` to `ClassFileAnnotation` in order to avoid silently ignoring non-literal UIDs like: @SerialVersionUID(0 - 12345L) class C And to flag non-constant UIDs: @SerialVersionUID("!!!".length) While this indeed was fold constants, the change was incomplete. The compiler API for reading the argument from a `ClassFileAnnoation` is different, on must look for a `LiteralAnnotArg`, rather than a `Literal`. This commit: - amends the backend accordingly - removes relevant duplication between `GenASM` and `GenBCode` - tests that the static field is generated accordingly This will mean that we will break deserialization of objects from Scalal 2.11.0 that use this annotation.
| * | | | | Merge pull request #3703 from huitseeker/issue/SI-8537Jason Zaugg2014-05-071-1/+10
| |\ \ \ \ \ | | | | | | | | | | | | | | SI-8537 Puts SI-8157 fix under Xsource
| | * | | | | SI-8537 Puts SI-8157 fix under XsourceFrançois Garillot2014-04-251-1/+10
| | |/ / / /
| * / / / / SI-8325 Accept infix star type outside patternsSom Snytt2014-05-051-9/+21
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a follow-up to SI-5702 which enabled use of `*` in infix notation in patterns. Most of the work is in distinguishing infix from a sequence pattern. Also, do not take backticked star as the repeated parameter marker in postfix position. That is, `Int``*``` is not `Int*` -- I hope double-tick renders as tick. There is not a special use case except that backticks mean "I am an identifier, as is, and not a keyword."
* | | | | Merge pull request #3721 from lrytz/t7852Jason Zaugg2014-05-084-22/+38
|\ \ \ \ \ | | | | | | | | | | | | SI-7852 for GenBCode
| * | | | | BCodeICodeCommon through composition rather than inheritanceLukas Rytz2014-05-084-4/+9
| | | | | |
| * | | | | SI-7852 for GenBCodeLukas Rytz2014-05-074-23/+34
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid null checks for "someLiteral".== and SomeModule.==. This has been implemented in GenICode in #2954. Introduces a trait to share code between GenICode and GenBCode. This is just a start, more such refactorings will come quite certainly.
* | | | | Merge pull request #3728 from retronym/topic/merge-2.10.xJason Zaugg2014-05-083-7/+18
|\ \ \ \ \ | | | | | | | | | | | | Merge 2.10.x to 2.11.x
| * \ \ \ \ Merge commit 'ec05aeb' into topic/merge-2.10.xJason Zaugg2014-05-083-7/+18
| |\ \ \ \ \ | | |/ / / / | |/| | | |
| | * | | | Merge pull request #3678 from retronym/ticket/8479Jason Zaugg2014-04-072-4/+11
| | |\ \ \ \ | | | | | | | | | | | | | | SI-8479 Fix constructor default args under scaladoc
| | | * | | | SI-8479 Fix constructor default args under scaladocJason Zaugg2014-04-072-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `DocDef` node hid the `DefDef` constructor from the scrutinee of the namer when determining if the class had constructor defaults or not. The current pattern for fixing these bugs is to delegate the check to `TreeInfo`, and account for the wrapper `DocDef` node. I've followed that pattern, but expressed my feelings about this approach in a TODO comment. Before this patch, the enclosed test failed with: error: not enough arguments for constructor SparkContext: (master: String, appName: String)SparkContext