summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Added -Xlog-implicit-conversions.Paul Phillips2012-01-0211-25/+46
| | | | | | | | | | | | | | | | | New command line option prints a message whenever the compiler inserts an implicit conversion. Implicit parameters are not under consideration here, since the primary motivation is to make it easy to inspect your code for unintentional conversions, since they can have dramatic performance implications. class A { def f(xs: Array[Byte]) = xs.size def g(xs: Array[Byte]) = xs.length } % scalac -Xlog-implicit-conversions logImplicits.scala logImplicits.scala:2: applied implicit conversion from xs.type to ?{val size: ?} = implicit def byteArrayOps(xs: Array[Byte]): scala.collection.mutable.ArrayOps[Byte] def f(xs: Array[Byte]) = xs.size ^
* Changed boxing of free mutable variables to be flexible wrt when liftcode ↵Martin Odersky2012-01-028-122/+105
| | | | | | takes place. A major redesign that unifies the various different approaches to boxing of free variables. Free variables are marked with CAPTURED and eliminated by LambdaLift. I also added some hooks in MacroContext that a reifier needs to use.
* Hardening of adaptoNewRun to survive issues in presentation compiler.Martin Odersky2012-01-021-4/+8
| | | | Previously, adaptToNewRun crashed when an object declaration got replaced by a value with the same name, because the module class no longer existed. This caused crashes in the presentation compiler when class files disappeared because of a clean build. The new behavior avoids assertion errors.
* More uniformity for the parser.Paul Phillips2011-12-311-4/+4
| | | | | | | | | | Fixing consecutive type application made it more obvious there was another missing bit of the parser, type application following function application. This should (and now does) work: object F { def apply[T] = List[T]() } def g() = F g()[String]
* More performance work.Paul Phillips2011-12-3017-470/+700
| | | | | | | Custom versions of collections which methods which operate on 2 or 3 collections. Eliminated most users of zip/zipped. Cleaned up the kinds checking code somewhat. Reduced the number of silent typechecks being performed at named argument sites.
* Low-level optimization.Paul Phillips2011-12-305-20/+23
| | | | Eliminated a bunch of unnecessary array expense.
* Created VariantTypeMap.Paul Phillips2011-12-303-139/+197
| | | | | | | Noticed most TypeMaps ignore variance but perform all the variance bookkeeping regardless. Made it so only variant TypeMaps pay that cost. Also lent some organization to the one place making real use of VariantTypeMap, existentialAbstraction.
* Creator for existentials which flattens.Paul Phillips2011-12-307-19/+22
| | | | | | Currently it is possible to end up with nested existentials, because existentialAbstraction only looks one level deeper. This works harder to flatten them.
* Better hunting for tools.jar.Paul Phillips2011-12-304-27/+51
| | | | | Attempting to make the repl find it based on fewer clues so all can enjoy the javap goodness.
* Optimization in refchecks.Paul Phillips2011-12-302-36/+51
| | | | | | | addVarargBridges is extremely expensive to cover such a corner case (scala classes inheriting and overriding java varargs methods.) Added a fast path excluding every class which doesn't have a java varargs method somewhere amidst its ancestors.
* Optimization in backend.Paul Phillips2011-12-301-4/+2
| | | | | | | Eliminated one source of the thousands of copies of the same Strings we had/have (strongly reachable) on the heap. It is another good example of how constructor parameters unintentionally become fields and how that in turn brings the pain.
* Optimization in Flags.Paul Phillips2011-12-301-5/+26
| | | | Added fast and less slow paths for oddly expensive flagsToString.
* Optimization in method synthesis.Paul Phillips2011-12-303-5/+9
| | | | | Discovered expensive flag operations being performed on the wrong side of the only-when-logging by-name argument.
* Optimizations in typeref creation.Paul Phillips2011-12-302-3/+3
| | | | | | A couple locations where more work than necessary is performed when created a typeref. (Not to mention creating bogus typerefs applying arguments to implementation classes.)
* repl power mode improvements.Paul Phillips2011-12-286-95/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implemented great suggestion from moors. More imports in power mode, including the contents of treedsl. Also, another swing at overcoming the mismatched global singletons problem, this time taking advantage of dependent method types. Amazingly, it seems to work. Continuing in the quest to create a useful compiler hacking environment, there is now an implicit from Symbol which allows you to pretend a Symbol takes type parameters, and the result is the applied type based on the manifests of the type arguments and the type constructor of the symbol. Examples: // magic with manifests scala> val tp = ArrayClass[scala.util.Random] tp: $r.global.Type = Array[scala.util.Random] // evidence scala> tp.memberType(Array_apply) res0: $r.global.Type = (i: Int)scala.util.Random // treedsl scala> val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) m: $r.treedsl.global.Match = 10 match { case 5 => false case _ => true } // typed is in scope scala> typed(m).tpe res1: $r.treedsl.global.Type = Boolean
* Tone down insensible-equality warning.Paul Phillips2011-12-271-1/+1
| | | | Closes SI-5175.
* Merge branch 'type-currying-mini' of /scala/trunk into developPaul Phillips2011-12-271-3/+4
|\
| * Consecutive type application.Paul Phillips2011-12-271-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | The parser through I think a quirk of history would not allow back to back type applications, like expr[T1, T2][T3, T4] Now it does, meaning the only thing it can: val n0 = Partial[immutable.HashMap][String][Int] ++ Seq(("a", 1)) val n1 = Partial.apply[immutable.HashMap].apply[String].apply[Int] ++ Seq(("a", 1)) assert(n0 == n1)
| |
| \
| \
| \
| \
| \
| \
| \
*-------. \ Merge remote-tracking branches 'ijuma/issue/5341', ↵Paul Phillips2011-12-272-0/+45
|\ \ \ \ \ \ | | |_|_|_|/ | |/| | | | | | | | | | 'kepler/topic/reifyclosuretests', 'kepler/topic/antscalacheck', 'szabolcsberecz/SI-5104', 'kepler/ticket/5334' and 'kepler/topic/miscfixes' into develop
| | | | | * Documented emptyValDef fieldEugene Burmako2011-12-231-0/+5
| | | | |/
| | | * / fixes #5104 and related NaN ordering inconsistenciesSzabolcs Berecz2011-12-251-0/+40
| | | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bug was caused by the inconsistency between j.l.Math.min() and j.l.Double.compareTo() wrt NaN (j.l.Math.min() considers NaN to be less than any other value while j.l.Double.compareTo() says it's greater...) The fix changes Ordering.{FloatOrdering,DoubleOrdering) to base it's results on primitive comparisons and math.{min,max} instead of j.l.{Float,Double}.compareTo()
* | | / Fix SI-5341: PhaseAssembly.removeDanglingNodes removes elements from mutable.MapIsmael Juma2011-12-271-1/+1
|/ / / | | | | | | | | | during iteration.
* / / Fixed regression in lub calculation.Paul Phillips2011-12-261-9/+17
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changing NullaryMethodType to be a SimpleTypeProxy because nearly all its operations forward to its result type was it seems not such a good idea, because it also meant that calling .underlying returned the result type rather than the method type. The way this materialized was in subtype checks of refinement types. A lub is calculated for two nullary method types in the course of calculating a refinement, and then the input types are checked against the calculated lub. However in the lub refinement, the nullary method type has become a bare typeref, and so the subtype check failed. Closes SI-5317. This does give me confidence that all the malformed lubs one sees logged under -Ydebug (and there are still many, especially with type constructors) are alerting us to real bugs elsewhere in Types.
* | Optimizing at the Name/String boundary.Paul Phillips2011-12-2511-87/+114
| | | | | | | | | | | | Working on reducing the now significant amount of both garbage and retained but duplicated Strings taking place as Names become Strings and vice versa. Long way to go.
* | Optimization in ZipArchive.Paul Phillips2011-12-251-4/+8
| | | | | | | | Avoid creating empty array when len == 0.
* | [vpm] when there's a default case, don't throw matcherrorAdriaan Moors2011-12-241-9/+16
| |
* | [vpm] lambdalift becomes less NSDNHO-proneAdriaan Moors2011-12-241-0/+1
| | | | | | | | made lambdalift complaint more useful
* | [vpm] emitting switches -- BodyTreeMakerAdriaan Moors2011-12-244-165/+298
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1) introduce BodyTreeMaker to get rid of special casing for body now each case is a list of TreeMakers rather than a pair of such a list and a tree needed to do this since emitting switches requires access to the untranslated body 2) emitting switches - alternatives are flattened: each alternative block ends with a jump to the next alternative (if there is one) - to avoid stack overflow in typedMatch: detect when translateMatch returns a Match the patch to uncurry would be nicer with an extractor, but that breaks due to a bug in old patmat made trees into dags again -- NPE in erasure tree.duplicate seems to break lambdalift because it does not give fresh symbols (or trees?) to the valdefs for the arguments of duplicated functions duplicate enclosing tree, not subtrees improved propagateSubstitution for AlternativesTreeMaker - it now propagates to all its alternatives, so we don't have to do that in chainBefore - by making propagation more regular, a bug in substitution in AlternativesTreeMaker manifested itself it introduced a new binder, unnecessarily, which then was unbound -- now reusing binder of outer pattern having removeSubstOnly in propagateSubstitution unveiled a bug: guard treemaker should substitute move fixerUpper closer to what it fixes up
* | [vpm] better codegen, especially for alternatives (suggested by Tiark)Adriaan Moors2011-12-243-246/+221
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | factored out some of the optimizing codegen that had snuck into treemakers (guardtreemaker) removed `caseResult`, back to just `one` no longer emitting intermediate `one`s (using guard instead -- when not optimizing) so uncurry can't accidentally blow them away (it removes the `one` that represents the case's result, but should leave intermediate computation alone) still TODO: reusing-treemakers sharing prefixes of length 1 helps inlining suffix of alternatives if small enough
* | [vpm] common sub-expression elimination for conditionsAdriaan Moors2011-12-242-81/+444
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TreeMakers (esp. CondTreeMakers) are approximated by hash-cons'ed Conds sharing is detected for prefixes of Conds, and shared conditions are only tested once their results are stored, and repeated tests branch on the last shared condition, reusing the results from the first time they were checked a Test is 1-to-1 with a TreeMaker, but may share its Cond TODO: clean separation of the two translation strategies: - naive flatMap/orElse (for virtualization) - less-naive if-then-else (with CSE etc coming) sharing trees caused wrong bytecode to be emitted (verifyerror) tentative explanation: "because lambdalift uses mutable state to track which variables have been captured if you refer to the same variable with the same tree twice it'll get confused" Sent at 8:27 PM on Thursday >> grzegorz.kossakowski: so we found a bug in jvm according to http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc2.html checkcast should throw a classcastexception becuase it's a shorthand for if !(x instanceof T) throw ClassCastExcpt but jvm decided to throw verifyerror and yeah, the check is wrong if jvm was not throwing verifyerror it would throw classcast exception saying that ObjectRef cannot be casted to $colon$colon ... >> me: so now where does it come from? since a ref is involved, i thought LambdaLift >> grzegorz.kossakowski: yup or now I don't think lambalift introduces that kind of low-level casts but I might be wrong btw. it's interesting that it unpacks stuff from objectref twice in your code and in one place checkcast is correct and in another is wrong Sent at 9:33 PM on Thursday >> grzegorz.kossakowski: also, since it's a verifyerror I think genjvm should have an assertion >> grzegorz.kossakowski: 193: getfield #54; //Field scala/runtime/ObjectRef.elem:Ljava/lang/Object; 196: checkcast #8; //class scala/runtime/ObjectRef 199: invokevirtual #95; //Method scala/collection/immutable/$colon$colon.tl$1:()Lscala/collection/immutable/List; it's this see you have checkcast for ObjectRef and then on that value, you try to call tl() method from List Sent at 9:56 PM on Thursday >> me: fixed sharing trees is bad very bad because lambdalift uses mutable state to track which variables have been captured if you refer to the same variable with the same tree twice it'll get confused
* | [vpm] optimized codegen avoids option-boxingAdriaan Moors2011-12-244-65/+160
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | introducing two mutable variables per pattern match: matchRes and keepGoing keepGoing denotes whether the result was Some or None, and matchRes holds the Some's contents or the right zero for the match's type Race(() => fastMatch(list), () => virtMatch_no_option(list))(100000).converge() is a virtual tie on my machine after this see https://gist.github.com/1400910 conveniently also works around SI-5245 don't assign to Unit-typed var's, in fact, make matchRes a val when its only prospect in life is to be unit-valued propagate eventual type for matchRes thru codegen so that we can have more robust checks for unit&nothing, when assignment makes no sense also, added a hack to caseResult to avoid boxed units in if(keepGoing) { matchRes = ... } else zero after erasure, we get if(keepGoing) { matchRes = ...; BoxedUNIT } else zero genicode broke because i was sharing trees: [scalacfork] error: java.lang.AssertionError: assertion failed: type error: can't convert from UNIT to REF(class Object) in unit ScalaSig.scala at source-/Users/adriaan/git/scala-dev/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala,line-26,offset=868 fixed by duplicating -- so be it (for now -- make this more fine-grained, more efficient) dodging inliner issues with one/zero (it won't inline, so also directly inline those methods)
* | [vpm] unapplyProd: faster matching for case classesAdriaan Moors2011-12-241-84/+178
|/ | | | | | | | | | | | | | | | | | | | | | | | | | behold the mythical unapplyProd: it does not exist, yet it promises to speed up pattern matching on case classes instead of calling the synthetic unapply/unapplySeq, we don't call the mythical synthetic unapplyProd, since -- if it existed -- it would be the identity anyway for case classes eventually, we will allow user-defined unapplyProd's, which should give you almost the same speed as case class matching for user-defined extractors (i.e., you don't have to wrap in an option, just return something on which we can select _i for i = 1 to N, unless it is null, which indicates match failure) still need to figure out a way to derive the types for the subpatterns, without requiring you to wrap your result in a ProductN unapplyProd support for vararg case classes using caseFieldAccessors instead of synthetic _i now the compiler bootstraps again, and after this optimization, quick.lib overhead is 70%, quick.comp is 50% (compiling with a locker built using -Yvirtpatmat, and itself generating code for -Yvirtpatmat) before the optimization, I think the overhead for quick.comp was close to 100% in this scenario more robust tupleSel for case classes TODO: - pos/t602 -- clean up after type inference as in fromCaseClassUnapply - run/pf-catch -- implement new-style orElse for partial function in uncurry
* global.abort calls global.error.Paul Phillips2011-12-222-2/+8
| | | | | | Otherwise it is possible (as I discovered the hard way) for tests running into compiler bugs to be treated as successful compiles.
* Hardening of resetAllAttrs.Martin Odersky2011-12-222-41/+44
| | | | Now works in the case where TypeTrees refer to locally erased symbols.
* Hardening of isJavaClass.Martin Odersky2011-12-221-1/+1
| | | | To survive IncompatibleClassChange errors.
* Omit non-essential TypeApply trees.Eugene Burmako2011-12-223-7/+6
| | | | Otherwise they cause type errors.
* Type checking now puts tree to be typed in local contextMartin Odersky2011-12-221-11/+31
|
*---. Merge remote-tracking branches 'jsuereth/xsbt', 'kepler/ticket/5226' and ↵Paul Phillips2011-12-215-165/+82
|\ \ \ | | | | | | | | | | | | 'kepler/topic/ystopafter' into develop
| | | * Made -Ystop-after:parser work correctlyEugene Burmako2011-12-211-2/+4
| |_|/ |/| | | | | | | | | | | Without this fix running a compiler with the aforementioned option leads to a crash (because namerPhase gets resolved to a NoPhase).
| | * Attempt to fix classloader issuesEugene Burmako2011-12-211-2/+4
| |/ |/| | | | | | | | | | | | | | | | | @odersky writes: When doing reflect.mirror.ClassWithName("foo") in the REPL, we get a NullPointerException. It goes away if we have this fallback in defaultClassLoader. Not sure it's the right fix, though. Fixes SI-5226, review by @odersky
| * Merge branch 'master' into xsbtJosh Suereth2011-12-206-51/+122
| |\ | |/ |/|
| * Merge branch 'master' into xsbtJosh Suereth2011-12-185-128/+351
| |\
| * \ Merge branch 'master' into xsbtJosh Suereth2011-12-147-30/+107
| |\ \
| * \ \ Merge remote-tracking branch 'origin/master' into xsbtPaul Phillips2011-12-091-2/+26
| |\ \ \
| * | | | Fixed Emit*Page to write to file.Josh Suereth2011-12-092-153/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The EmitHtmlPage and EmitManPage utilities now write to a file if there is more than one argument on the command line. This allows the SBT build to fork them and still generate a file without having to capture the output stream.
| * | | | Merge branch 'master' into xsbtJosh Suereth2011-12-092-9/+13
| |\ \ \ \
| * \ \ \ \ Merge branch 'master' into xsbtJosh Suereth2011-12-0841-189/+155
| |\ \ \ \ \
| * \ \ \ \ \ Merge branch 'master' into xsbtPaul Phillips2011-12-0645-60/+60
| |\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: project/build/ScalaSBTBuilder.scala
| * \ \ \ \ \ \ Merge branch 'master' into xsbtJosh Suereth2011-12-0630-3/+93
| |\ \ \ \ \ \ \
| * \ \ \ \ \ \ \ Merge branch 'master' into xsbtJosh Suereth2011-12-053-7/+31
| |\ \ \ \ \ \ \ \