Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit ffcf073

Browse files
committed
Merge pull request scala#4584 from lrytz/merge-2.11-to-2.12-june-26
Merge 2.11 to 2.12 june 26
2 parents d90d8b8 + af7065f commit ffcf073

22 files changed

+1282
-137
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ We follow the standard GitHub [fork & pull](https://help.github.com/articles/usi
44
You're always welcome to submit your PR straight away and start the discussion (without reading the rest of this wonderful doc, or the `READMEnot^H^H^H.md`). The goal of these notes is to make your experience contributing to Scala as smooth and pleasant as possible. We're happy to guide you through the process once you've submitted your PR.
55

66
## The Scala Community
7-
Last year, you -- the Scala community -- matched the core team at EPFL in number of commits contributed to Scala 2.11, doubling the percentage of commits from outside EPFL/Typesafe since 2.10. Excellent work! (The split is roughly 25/25/50 for you/epfl/typesafe. By the way, the team at Typesafe is: @adriaanm, @gkossakowski, @lrytz and @retronym.)
7+
In 2014, you -- the Scala community -- matched the core team at EPFL in number of commits contributed to Scala 2.11, doubling the percentage of commits from outside EPFL/Typesafe since 2.10. Excellent work! (The split was roughly 25/25/50 for you/EPFL/Typesafe.)
88

99
We are super happy about this, and are eager to make your experience contributing to Scala productive and satisfying, so that we can keep up this growth. We can't do this alone (nor do we want to)!
1010

1111
This is why we're collecting these notes on how to contribute, and we hope you'll share your experience to improve the process for the next contributor! (Feel free to send a PR for this note, send your thoughts to scala-internals, or tweet about it to @adriaanm.)
1212

13+
By the way, the team at Typesafe is: @adriaanm, @lrytz, @retronym, and @SethTisue.
14+
1315
## What kind of PR are you submitting?
1416

15-
Regardless of the nature of your Pull Request, we have to ask you to sign the [Scala CLA](http://typesafe.com/contribute/cla/scala), to protect the OSS nature of the code base.
17+
Regardless of the nature of your Pull Request, we have to ask you to digitally sign the [Scala CLA](http://typesafe.com/contribute/cla/scala), to protect the OSS nature of the code base.
18+
19+
You don't need to submit separate PRs for 2.11.x, 2.12.x, and 2.13.x. Any changes accepted on one of these branches will, in time, be merged into the later branches.
1620

1721
### Documentation
1822
Whether you finally decided you couldn't stand that annoying typo anymore, you fixed the outdated code sample in some comment, or you wrote a nice, comprehensive, overview for an under-documented package, some docs for a class or the specifics about a method, your documentation improvement is very much appreciated, and we will do our best to fasttrack it.
@@ -28,9 +32,9 @@ The kind of code we can accept depends on the life cycle for the release you're
2832

2933
#### Bug Fix
3034

31-
Prefix your commit title with "SI-NNNN", where https://issues.scala-lang.org/browse/SI-NNNN tracks the bug you're fixing. We also recommend naming your branch after the Jira ticket number.
35+
Prefix your commit title with "SI-NNNN", where https://issues.scala-lang.org/browse/SI-NNNN tracks the bug you're fixing. We also recommend naming your branch after the JIRA ticket number.
3236

33-
Please make sure the Jira ticket's fix version corresponds to the upcoming milestone for the branch your PR targets (the CI automation will automatically assign the milestone after you open the PR).
37+
Please make sure the JIRA ticket's fix version corresponds to the upcoming milestone for the branch your PR targets. The CI automation will automatically assign the milestone after you open the PR.
3438

3539
#### Enhancement or New Feature
3640

@@ -49,4 +53,3 @@ A new language feature requires a SIP (Scala Improvement Process) proposal. For
4953
- [Boy Scout Rule](http://programmer.97things.oreilly.com/wiki/index.php/The_Boy_Scout_Rule) should be applied.
5054

5155
Please also have a look at our [Pull Request Policy](https://github.com/scala/scala/wiki/Pull-Request-Policy), as well as the [Scala Hacker Guide](http://www.scala-lang.org/contribute/hacker-guide.html) by @xeno-by.
52-

spec/05-classes-and-objects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ This form of extensibility can be excluded by declaring the base class
964964
directly extend `Expr` must be in the same source file as
965965
`Expr`.
966966

967-
### Traits
967+
## Traits
968968

969969
```ebnf
970970
TmplDef ::= `trait' TraitDef

src/build/InnerObjectTestGen.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ object Contexts extends Enumeration {
2222
* object, or equivalent).
2323
*
2424
* Usage: TestGen <nr of levels>
25-
* - by default it's 2 leves. Currently, 3-level deep uncovers bugs in the type checker.
25+
* - by default it's 2 levels. Currently, 3-level deep uncovers bugs in the type checker.
2626
*
2727
* @author Iulian Dragos
2828
*/

src/compiler/scala/tools/nsc/backend/jvm/BCodeIdiomatic.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ abstract class BCodeIdiomatic extends SubComponent {
436436
else { emitTypeBased(JCodeMethodN.returnOpcodes, tk) }
437437
}
438438

439-
/* Emits one of tableswitch or lookoupswitch.
439+
/* Emits one of tableswitch or lookupswitch.
440440
*
441441
* can-multi-thread
442442
*/

src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers {
140140
if (AsmUtils.traceClassEnabled && cnode.name.contains(AsmUtils.traceClassPattern))
141141
AsmUtils.traceClass(cnode)
142142

143-
if (settings.YoptInlinerEnabled) {
143+
if (settings.YoptAddToBytecodeRepository) {
144144
// The inliner needs to find all classes in the code repo, also those being compiled
145145
byteCodeRepository.add(cnode, ByteCodeRepository.CompilationUnit)
146146
}

src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ abstract class BTypes {
4444

4545
val inliner: Inliner[this.type]
4646

47+
val closureOptimizer: ClosureOptimizer[this.type]
48+
4749
val callGraph: CallGraph[this.type]
4850

4951
val backendReporting: BackendReporting
@@ -940,7 +942,7 @@ abstract class BTypes {
940942
*/
941943
def jvmWiseLUB(other: ClassBType): Either[NoClassBTypeInfo, ClassBType] = {
942944
def isNotNullOrNothing(c: ClassBType) = !c.isNullType && !c.isNothingType
943-
assert(isNotNullOrNothing(this) && isNotNullOrNothing(other), s"jvmWiseLub for null or nothing: $this - $other")
945+
assert(isNotNullOrNothing(this) && isNotNullOrNothing(other), s"jvmWiseLUB for null or nothing: $this - $other")
944946

945947
tryEither {
946948
val res: ClassBType = (this.isInterface.orThrow, other.isInterface.orThrow) match {
@@ -965,7 +967,7 @@ abstract class BTypes {
965967
firstCommonSuffix(this :: this.superClassesTransitive.orThrow, other :: other.superClassesTransitive.orThrow)
966968
}
967969

968-
assert(isNotNullOrNothing(res), s"jvmWiseLub computed: $res")
970+
assert(isNotNullOrNothing(res), s"jvmWiseLUB computed: $res")
969971
Right(res)
970972
}
971973
}

src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package scala.tools.nsc
77
package backend.jvm
88

99
import scala.tools.asm
10-
import scala.tools.nsc.backend.jvm.opt.{LocalOpt, CallGraph, Inliner, ByteCodeRepository}
10+
import scala.tools.nsc.backend.jvm.opt._
1111
import scala.tools.nsc.backend.jvm.BTypes.{InlineInfo, MethodInlineInfo, InternalName}
1212
import BackendReporting._
1313
import scala.tools.nsc.settings.ScalaSettings
@@ -42,6 +42,8 @@ class BTypesFromSymbols[G <: Global](val global: G) extends BTypes {
4242

4343
val inliner: Inliner[this.type] = new Inliner(this)
4444

45+
val closureOptimizer: ClosureOptimizer[this.type] = new ClosureOptimizer(this)
46+
4547
val callGraph: CallGraph[this.type] = new CallGraph(this)
4648

4749
val backendReporting: BackendReporting = new BackendReportingImpl(global)

src/compiler/scala/tools/nsc/backend/jvm/BackendReporting.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,28 @@ object BackendReporting {
246246
case class ResultingMethodTooLarge(calleeDeclarationClass: InternalName, name: String, descriptor: String,
247247
callsiteClass: InternalName, callsiteName: String, callsiteDesc: String) extends CannotInlineWarning
248248

249+
/**
250+
* Used in `rewriteClosureApplyInvocations` when a closure apply callsite cannot be rewritten
251+
* to the closure body method.
252+
*/
253+
trait RewriteClosureApplyToClosureBodyFailed extends OptimizerWarning {
254+
def pos: Position
255+
256+
override def emitWarning(settings: ScalaSettings): Boolean = this match {
257+
case RewriteClosureAccessCheckFailed(_, cause) => cause.emitWarning(settings)
258+
case RewriteClosureIllegalAccess(_, _) => settings.YoptWarningEmitAtInlineFailed
259+
}
260+
261+
override def toString: String = this match {
262+
case RewriteClosureAccessCheckFailed(_, cause) =>
263+
s"Failed to rewrite the closure invocation to its implementation method:\n" + cause
264+
case RewriteClosureIllegalAccess(_, callsiteClass) =>
265+
s"The closure body invocation cannot be rewritten because the target method is not accessible in class $callsiteClass."
266+
}
267+
}
268+
case class RewriteClosureAccessCheckFailed(pos: Position, cause: OptimizerWarning) extends RewriteClosureApplyToClosureBodyFailed
269+
case class RewriteClosureIllegalAccess(pos: Position, callsiteClass: InternalName) extends RewriteClosureApplyToClosureBodyFailed
270+
249271
/**
250272
* Used in the InlineInfo of a ClassBType, when some issue occurred obtaining the inline information.
251273
*/

src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,20 +216,25 @@ abstract class GenBCode extends BCodeSyncAndTry {
216216
class Worker2 {
217217
def runGlobalOptimizations(): Unit = {
218218
import scala.collection.convert.decorateAsScala._
219-
q2.asScala foreach {
220-
case Item2(_, _, plain, _, _) =>
221-
// skip mirror / bean: wd don't inline into tem, and they are not used in the plain class
222-
if (plain != null) callGraph.addClass(plain)
219+
if (settings.YoptBuildCallGraph) {
220+
q2.asScala foreach {
221+
case Item2(_, _, plain, _, _) =>
222+
// skip mirror / bean: wd don't inline into tem, and they are not used in the plain class
223+
if (plain != null) callGraph.addClass(plain)
224+
}
223225
}
224-
bTypes.inliner.runInliner()
226+
if (settings.YoptInlinerEnabled)
227+
bTypes.inliner.runInliner()
228+
if (settings.YoptClosureElimination)
229+
closureOptimizer.rewriteClosureApplyInvocations()
225230
}
226231

227232
def localOptimizations(classNode: ClassNode): Unit = {
228233
BackendStats.timed(BackendStats.methodOptTimer)(localOpt.methodOptimizations(classNode))
229234
}
230235

231236
def run() {
232-
if (settings.YoptInlinerEnabled) runGlobalOptimizations()
237+
runGlobalOptimizations()
233238

234239
while (true) {
235240
val item = q2.poll

src/compiler/scala/tools/nsc/backend/jvm/analysis/InstructionStackEffect.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ object InstructionStackEffect {
9494
val isSize2 = peekStack(0).getSize == 2
9595
if (isSize2) t(1, 0) else t(2, 0)
9696

97-
case DUP => t(0, 1)
97+
case DUP => t(1, 2)
9898

9999
case DUP_X1 => t(2, 3)
100100

@@ -104,7 +104,7 @@ object InstructionStackEffect {
104104

105105
case DUP2 =>
106106
val isSize2 = peekStack(0).getSize == 2
107-
if (isSize2) t(0, 1) else t(0, 2)
107+
if (isSize2) t(1, 2) else t(2, 4)
108108

109109
case DUP2_X1 =>
110110
val isSize2 = peekStack(0).getSize == 2

0 commit comments

Comments
 (0)