summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/ant/Scalac.scala
Commit message (Collapse)AuthorAgeFilesLines
* Fields does bitmaps & synch for lazy vals & modulesAdriaan Moors2016-08-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 commit '90706b0' into merge-2.11-to-2.12-june-1Lukas Rytz2016-06-011-2/+0
|\
| * Remove default value for sourcepath in scalac (ant version). (#5166)Krzysztof Romanowski2016-05-171-2/+0
| |
* | General cleanups and less warnings during a Scala buildsoc2016-04-041-1/+1
| |
* | Remove unused imports and other minor cleanupsSimon Ochsenreither2015-12-181-5/+3
| | | | | | | | | | | | | | | | | | | | - Language imports are preceding other imports - Deleted empty file: InlineErasure - Removed some unused private[parallel] methods in scala/collection/parallel/package.scala This removes hundreds of warnings when compiling with "-Xlint -Ywarn-dead-code -Ywarn-unused -Ywarn-unused-import".
* | Update some phase listsSimon Ochsenreither2015-11-251-1/+1
| |
* | Remove ICodeSimon Ochsenreither2015-10-311-2/+2
|/
* Fix 23 typos (t-v)Janek Bogucki2015-07-151-1/+1
|
* Fix many typos in docs and commentsmpociecha2014-12-141-1/+1
| | | | | | | | | | | | | This commit corrects many typos found in scaladocs, comments and documentation. It should reduce a bit number of PRs which fix one typo. There are no changes in the 'real' code except one corrected name of a JUnit test method and some error messages in exceptions. In the case of typos in other method or field names etc., I just skipped them. Obviously this commit doesn't fix all existing typos. I just generated in IntelliJ the list of potential typos and looked through it quickly.
* SI-8966 Allow use of jvm-1.8 via the Ant scalac taskJason Zaugg2014-11-071-1/+1
| | | | | | | | | | | This option has been allowed by the command line compiler since ee706b873a28. This commit allows use of this via Ant. Note: we still don't exploit the features of classfile version 52, but watch this space as we roll out method handle based closures soon!
* Add a skeletal Delambdafy phase.James Iry2013-11-011-1/+1
| | | | | | This commit adds a do-nothing phase called "Delambdafy" that will eventually be responsible for doing the final translation of lambdas into classes.
* Disentangled RangePositions from interactive.Paul Phillips2013-03-041-5/+1
| | | | | | | This is a stepping stone to having range positions all the time, as well as to modularizing the presentation compiler. It does not enable range positions by default, only places them smoewhere where they can be.
* Address some ScaladocrotJason Zaugg2013-02-251-1/+1
| | | | | | - @param tags whose name drifted from the corresponding parameter - Remove or complete a few stray stub comments (@param foo ...) - Use @tparam where appropriate.
* Be explicit about empty param list calls.Jason Zaugg2013-02-241-1/+1
| | | | With the exception of toString and the odd JavaBean getter.
* Merge commit 'refs/pull/1718/head' into merge-msil-genjvm-deletePaul Phillips2012-12-061-14/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'refs/pull/1718/head': Expunged the .net backend. Conflicts: build.detach.xml build.examples.xml build.xml project/Build.scala src/compiler/scala/tools/ant/Scalac.scala src/compiler/scala/tools/nsc/Global.scala src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala src/compiler/scala/tools/nsc/transform/Mixin.scala src/intellij/compiler.iml.SAMPLE tools/buildcp
| * Expunged the .net backend.Paul Phillips2012-12-051-14/+1
| | | | | | | | | | | | | | | | It lives on in a branch born from this commit's parent. It's abrupt; no attempt is made to offer a "smooth transition" for the serious msil userbase, population zero. If anyone feels very strongly that such a transition is necessary, I will be happy to talk you into feeling differently.
* | SI-6769 Removes GenJVM backendJames Iry2012-12-051-1/+1
|/ | | | | Get rid of GenJVM and everything that refers to it. Also get rid of GenAndroid since it's dead code that refers to GenJVM.
* Merge commit 'refs/pull/1574/head' into merge-210Paul Phillips2012-11-051-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'refs/pull/1574/head': (24 commits) Fixing issue where OSGi bundles weren't getting used for distribution. Fixes example in Type.asSeenFrom Fix for SI-6600, regression with ScalaNumber. SI-6562 Fix crash with class nested in @inline method Brings copyrights in Scaladoc footer and manpage up-to-date, from 2011/12 to 2013 Brings all copyrights (in comments) up-to-date, from 2011/12 to 2013 SI-6606 Drops new icons in, replaces abstract types placeholder icons SI-6132 Revisited, cleaned-up, links fixed, spelling errors fixed, rewordings Labeling scala.reflect and scala.reflect.macros experimental in the API docs Typo-fix in scala.concurrent.Future, thanks to @pavelpavlov Remove implementation details from Position (they are still under reflection.internal). It probably needs more cleanup of the api wrt to ranges etc but let's leave it for later SI-6399 Adds API docs for Any and AnyVal Removing actors-migration from main repository so it can live on elsewhere. Fix for SI-6597, implicit case class crasher. SI-6578 Harden against synthetics being added more than once. SI-6556 no assert for surprising ctor result type Removing actors-migration from main repository so it can live on elsewhere. Fixes SI-6500 by making erasure more regular. Modification to SI-6534 patch. Fixes SI-6559 - StringContext not using passed in escape function. ... Conflicts: src/actors-migration/scala/actors/migration/StashingActor.scala src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala src/compiler/scala/tools/nsc/settings/AestheticSettings.scala src/compiler/scala/tools/nsc/transform/Erasure.scala src/library/scala/Application.scala src/library/scala/collection/immutable/GenIterable.scala.disabled src/library/scala/collection/immutable/GenMap.scala.disabled src/library/scala/collection/immutable/GenSeq.scala.disabled src/library/scala/collection/immutable/GenSet.scala.disabled src/library/scala/collection/immutable/GenTraversable.scala.disabled src/library/scala/collection/mutable/GenIterable.scala.disabled src/library/scala/collection/mutable/GenMap.scala.disabled src/library/scala/collection/mutable/GenSeq.scala.disabled src/library/scala/collection/mutable/GenSet.scala.disabled src/library/scala/collection/mutable/GenTraversable.scala.disabled src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled
| * Brings all copyrights (in comments) up-to-date, from 2011/12 to 2013Heather Miller2012-11-021-1/+1
| |
* | Make the scalac Ant task recognise -YrangeposStuart Golodetz2012-09-131-1/+5
|/ | | | | | The scalac Ant task was not setting up the Scala compiler to produce range positions when specifying the -Yrangepos flag in its addparams property.
* Updated list of targets allowed in Ant's scalac.Grzegorz Kossakowski2012-07-191-1/+1
| | | | | | It looks like scala.tools.ant.Scalac class had a stale list of allowed targets. Made it in sync with what compiler supports.
* scalac ant task now supports all GenASM targetsMiguel Garcia2012-07-081-1/+1
|
* GenASM becomes default backend, 1.5 classfiles remain as defaultMiguel Garcia2012-07-061-1/+1
|
* Reverting 22c8dec5 and preventing bootstapping in scaladocVlad Ureche2012-06-081-28/+15
| | | | | Review by @dragos, @jsuereth. Required bootstrapping because the starr was ant tasks were invoking locker with -Ysourcepath instead of -sourcepath.
* Fixes SI-4909 and SI-5763Vlad Ureche2012-06-081-15/+28
| | | | | | | | | | Finally, -sourcepath is split into: -Ysourcepath - for the library bootstrapping -doc-source-path - for scaladoc links to source code (squished the resident compiler test fix into this commit) Review by @jsuereth.
* miscellaneous cleanup, mostly fighting with feature warningsEugene Burmako2012-06-081-1/+1
|
* Replaced LiftCode with a function in MacroContextEugene Burmako2012-02-051-1/+1
| | | | | | | | | | | | | | Major cleanup of reification: * LiftCode phase has been removed * Code has been deprecated and will be removed as we roll a new starr * Logic related to type-directed lifting has been purged scala.reflect.macro.Context#reify now provides the same services as LiftCode provided (except that it returns Tree, not Code). For testing purposes, I've retained the oh-so-convenient automagic lift. test/files/codelib/code.jar now hosts Code.lift reimplemented in a macro, so that the tests can continue working as if nothing has happened.
* Linked up $class visibility to symbol redefinition.Paul Phillips2012-01-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In what feels like divine intervention as I spent my entire day yesterday unsuccessfully attempting to understand why running atop my new classpath code, trunk would compile and then fail like this: build.xml:1683: Could not create type partest due to java.lang.NoSuchMethodError: scala.tools.ant.sabbus.CompilationPathProperty$class.$init$(Lscala/tools/ant/sabbus/CompilationPathProperty;)V I discovered the link by trying to debug a seemingly completely unrelated problem reported by pvlugter. On the one hand you have PathResolver/ClassPath, which by default does not place trait implementation classes on the compilation classpath, but does do so under -optimise (as I understand it, this is so inlining can be performed, so let us ignore the fact that methods in traits are never inlined, as outlined in SI-4767.) object DefaultJavaContext extends JavaContext { override def isValidName(name: String) = !isTraitImplementation(name) } Then on the other hand you have this logic in AddInterfaces: if (impl != NoSymbol && settings.optimise.value) { log("unlinking impl class " + impl) ... } The test in AddInterfaces is hardcoded to only consider the value of -optimise. Which means that in the completely default -optimise setup, it corresponds to the answers given by "isValidName" in JavaContext, but nothing keeps those elements in sync. The connection to my lost day was that, thinking I was "simplifying" my development, I had commented out the override in DefaultJavaContext so that all classes were on the compilation path. This caused the state of settings.optimise (still false) and whether impl classes were on the classpath (now true) to fall into fatal disagreement.
* attempt to fix reopened SI-5196michelou2011-11-271-4/+13
|
* Updated/fixed the following two Scala Ant tasks:michelou2011-11-161-16/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | scalac (ant.Scalac) - added attributes `dependencyfile`, `explaintypes`, `nobootcp`, `nowarn` and `usejavacp` - added support for nested element `compilerarg` (see Ant manual) in order to pass prefix settings (eg. -J-Xbootclasspath, -Ddebug=true) to nsc.CompileClient - updated list of permissible values for compiler phases fsc (ant.FastScalac) - added attributes `ip4` and `maxIdle` in addition to `reset`, `server` and `shutdown` (and forwards them to nsc.CompileClient) - also forwards prefix settings `jvmargs` and `defines`, and boolean settings `explaintypes`, `nospecialization`, `nowarn`, `optimise`, `unchecked` and `usejavacp` to nsc.CompileClient - fixed CompileClient.process if-test Nota Bene I added the following element to partest.PartestTask (commit is pending) in order to automatically test the Scala Ant tasks: <anttests dir="${partest.dir}/${partest.srcdir}/ant" includes="*build.xml"/> Here is the output: [user@localhost scala]$ ant test.ant Buildfile: /home/user/workspace/scala/build.xml [echo] Forking with JVM opts: -Xms1536M [...] init: [echo] Build number is '2.10.0.r26022-b20111116212958' [echo] Built 16 November 2011, 21:29:58 [...] [...] test.ant: [partest] Running ant task tests [partest] testing: [...]/files/ant/fsc-build.xml [ OK ] [partest] testing: [...]/files/ant/scaladoc-build.xml [ OK ] [partest] testing: [...]/files/ant/scalac-build.xml [ OK ] [partest] Test suite finished with no failures. BUILD SUCCESSFUL Total time: 12 seconds
* Partially reverted r25636 change (forget notice...michelou2011-09-121-29/+16
| | | | | | | | | | | | | | | Partially reverted r25636 change (forget notice about the starr rebuild). Change originated in my misunderstanding of Ant filters: The pattern string if <exclude name="<pattern>"/> may not contain Ant variables such as eg. ${compiler.excludes}. Use <excludesfile name="${compiler.excludes}" if="<property>"/> instead !
* added missing getExcludedFiles in <scalac> Ant ...michelou2011-09-081-10/+22
| | | | | | | | | added missing getExcludedFiles in <scalac> Ant task (same change is pending for <pending> Ant task). A new starr is needed for that features to work in build.xml (and other Ant scripts).
* 4th round of clean ups (see r25293, r25285, r25...michelou2011-07-201-109/+99
| | | | | 4th round of clean ups (see r25293, r25285, r25292)
* More batched performance improvements for io.{ ...Paul Phillips2011-06-141-1/+1
| | | | | | | | | More batched performance improvements for io.{ File, Classpath } and others in the neighborhood. Avoids calling the expensive getCanonicalPath in favor of getAbsolutePath: I note that because it has the potential to change compiler behavior at the borders. No review.
* Updated copyright notices to 2011Antonio Cunei2011-01-201-1/+1
|
* Stops barking up the wrong tree with -Ywarn-dea...Paul Phillips2010-12-151-1/+0
| | | | | | | | | | | | | Stops barking up the wrong tree with -Ywarn-dead-code. The origin of its issues was twofold: 1) synchronized acts by-name without being by-name (ticket #4086) 2) warnings are swallowed if context.reportGeneralErrors is false Those two plus a dash of bitrot. In any case it's at its all time happiest now. It found all the dead code related fixes in this commit. Way to go, -Ywarn-dead-code! Review by odersky.
* Mopping up after the deprecation of exit and er...Paul Phillips2010-12-051-25/+17
| | | | | | | | | | | | | | Mopping up after the deprecation of exit and error. It is decidedly non-trivial (at least for the IDE-impaired) to be completely sure of which error function was being called when there were about twenty with the same signature in trunk and they are being variously inherited, imported, shadowed, etc. So although I was careful, the possibility exists that something is now calling a different "error" function than before. Caveat programmer. (And let's all make it our policy not to name anything "error" or "exit" from here on out....) No review.
* Unreverting r23174. No review.Paul Phillips2010-10-061-1/+1
|
* Reverts r23174, which I believe will bring the ...Paul Phillips2010-10-041-1/+1
| | | | | | Reverts r23174, which I believe will bring the build back to life. It only chokes under -optimise. No review.
* Work on the pattern matcher.Paul Phillips2010-10-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | patches for #3887 and #3888, but I determined that I could achieve the same effect by deleting a bunch of code, so I did. This left only a few lines in TransMatch, so I eliminated it, which led me to remember that many places still reference non-existent phase transmatch, so those were updated. Notes: * This swaps equality tests on stable identifier patterns. They have never conformed to the spec (as noted long ago in ticket #785) which says "The pattern matches any value v such that r == v" whereas until now the test being performed was v == r. * An issue was introduced with specialization in that the implementation of "isTupleType" in Definitions relied upon sym == TupleClass(elems.length). This test is untrue for specialized tuples, causing mysterious behavior because only some tuples are specialized. There is now "isTupleTypeOrSubtype" although it seems likely the former implementation is unnecessary. The issue is sidestepped if one uses "getProductArgs" to retrieve the element types because it sifts through the base types for the Product symbol. Closes #3887 and #3888, review by dmharrah.
* Removed more than 3400 svn '$Id' keywords and r...Antonio Cunei2010-05-121-1/+0
| | | | | Removed more than 3400 svn '$Id' keywords and related junk.
* While working on partest discovered that Compil...Paul Phillips2010-03-251-1/+1
| | | | | | | | | | | | | | | | | | | While working on partest discovered that CompilerCommand ignores half its constructor arguments and a couple dozen places blithely pass it those arguments as if they're being used. Then there were setups like this: class OfflineCompilerCommand( arguments: List[String], settings: Settings, error: String => Unit, interactive: Boolean) extends CompilerCommand(arguments, new Settings(error), error, false) Hey offline compiler command, why throw away the perfectly good settings you were given? Ever heard 'reduce, reuse, recycle'? How did you ever work... or do you? No review.
* escape source file path with space charsdcaoyuan2010-03-061-1/+1
|
* More laboring on Settings, ClassPaths, Ant Task...Paul Phillips2010-02-221-8/+4
| | | | | | More laboring on Settings, ClassPaths, Ant Tasks, Partest, and similar epicenters of thrilldom. No review.
* Digging into why the repl is so slow, discovere...Paul Phillips2010-01-191-1/+1
| | | | | | | | | | | | | | | | | | Digging into why the repl is so slow, discovered that fsc is once again never reusing compiler instances (but for a different reason than #1683.) Small changes break equality and the little troopers are so darn quiet about it. Steady state, hot fsc repl startup times before this patch: 0m1.747s 0m1.789s 0m1.842s 0m1.690s After this patch: 0m1.139s 0m1.148s 0m1.090s 0m1.091s No review. Could use a test case but I have trouble coaxing partest this far outside the box.
* Another round of deprecation warning elimination.Paul Phillips2009-12-151-1/+1
|
* Updated copyright notices to 2010Antonio Cunei2009-12-071-1/+1
|
* Split command line parameters by space, properl...dcaoyuan2009-12-051-1/+1
| | | | | | Split command line parameters by space, properly process quoted parameter
* Removed redundant code, let CompilerCommand pro...dcaoyuan2009-11-271-51/+9
| | | | | Removed redundant code, let CompilerCommand processes all params
* Fixed #2631dcaoyuan2009-11-181-7/+63
|