summaryrefslogtreecommitdiff
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* 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-242-231/+212
| | | | | | | | | | | | | | | 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-243-65/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-212-4/+8
|\ \ | | | | | | | | | '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
* Fix for classOf NPE.Paul Phillips2011-12-193-20/+35
| | | | Let type parameter be inferred. Closes SI-4871.
* Fixed "Definition Classes" in bug #5287Vlad Ureche2011-12-162-21/+23
|
* Fix for seq/array varargs crasher.Paul Phillips2011-12-131-1/+3
| | | | Closes SI-4024.
* Faster char2uescape.Paul Phillips2011-12-131-16/+20
| | | | | No StringBuilder, no closure, no toHexString, no string concatenation, no unnecessary math, no call to reverse, only the necessary allocation.
*---. Merge remote-tracking branches 'kepler/topic/typeparamsfix', ↵Paul Phillips2011-12-122-0/+5
|\ \ \ | | | | | | | | | | | | 'kepler/ticket/5295' and 'blair/clarify-Map-withDefaultValue' into develop
| | * | Batch files no longer swallow exit codesEugene Burmako2011-12-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Usually scripts like scala.bat and scalac.bat correctly propagate exit codes from underlying Java invocations. However, if you run these scripts as follows: "cmd /c scala ...", then errorlevel gets swallowed. This simple patch fixes the aforementioned problem. Fixes SI-5295, no review.
| * | | typeParams now performs one more completionEugene Burmako2011-12-121-0/+4
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When tracking a problem in type inference during reflective compilation, Martin and I have discovered that under certain circumstances typeParams does not fully load the type. During a debugging session we found out that info first had the type of TopLevelCompleter, and after the load it was still not completed, having the type of UnPickler$something$LazyTypeRef. After that discovery it became apparent that typeParams need to behave similarly to the info getter - allow for two completions, not just one. Review by @odersky, @adriaanm.
* / / Added per-file stats to -Dscala.timings.Paul Phillips2011-12-091-2/+26
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | % pscalac -Dscala.timings ./src/library/scala/util/*.scala phase id ms share ----------------------- -- ---- ----- typer 4 3632 44.73 specialize 13 1175 14.47 erasure 15 800 9.85 jvm 27 504 6.21 icode 22 427 5.26 ... ms path -------- ---------------------------------------------- 1056.667 ./src/library/scala/util/Sorting.scala 1019.369 ./src/library/scala/util/MurmurHash.scala 702.881 ./src/library/scala/util/Properties.scala 435.053 ./src/library/scala/util/Random.scala 429.702 ./src/library/scala/util/MurmurHash3.scala 246.453 ./src/library/scala/util/DynamicVariable.scala 69.755 ./src/library/scala/util/Marshal.scala
* | Merge remote-tracking branches 'VladUreche/issue/5054' and ↵Paul Phillips2011-12-0814-27/+48
|\| | | | | | | 'jsuereth/dont_resolve_releases'
| *---. Merge remote-tracking branches 'soc/SI-4990', ↵Paul Phillips2011-12-073-7/+10
| |\ \ \ | | | | | | | | | | | | | | | 'fedgehog/docs_fix_for_scala.Either.cond___SI-5113' and 'kepler/ticket/5266' into develop
| | | | * Fix reflective toolbox producing invalid bytecodeEugene Burmako2011-12-071-3/+4
| | | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Wrapper method for AST undergoing a reflective compilation has been incorrectly marked as static. This was off the radars until one day the code being compiled declared a top-level method. During flatten that method got hoisted into the wrapper module, and its invocation got translated into an instance call upon the module. This led to static wrapper method trying to call an instance method, and that blew up the bytecode verifier. More info: https://issues.scala-lang.org/browse/SI-5266. Fixes SI-5266, review by @odersky.
| | * / Migration message and version cleanupSimon Ochsenreither2011-12-072-4/+6
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | The @migration annotation can now be used like @deprecation. Old syntax is still supported, but deprecated. Improve wording and consistency of migration messages, migration warnings also print the version in which the change occurred now. Partially fixes SI-4990.
| * | Merge remote-tracking branch 'kepler/topic/reflectivecompiler' into developPaul Phillips2011-12-071-0/+6
| |\ \
| | * | Reflective compiler now crashes properlyEugene Burmako2011-12-071-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adjust toolbox to escalate errors reported during reflective compilation. Without this functionality, errors get swallowed and lead to weirdness like https://issues.scala-lang.org/browse/SI-5274. The only meaningful part of the output in the bug report linked above is the first line. Subsequent stack trace is at best useless and at worst misleading. Now the error report is much more sane: https://gist.github.com/1443232 Review by @odersky.
| * | | More warnings eliminations.Paul Phillips2011-12-0711-20/+32
| | |/ | |/| | | | | | | | | | Deprecation warnings, unchecked warnings, "that's not the value you think it is" warnings. Also eliminated a warning by fixing a warning bug.
* / | Fixed #5054, #5287Vlad Ureche2011-12-082-9/+13
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The documents with use cases should be restructured like: /** * The full definition, either used with an implicit value or with an explicit one. * * Some more explanation on implicits... * * @param lost a lost parameter * @return some integer * * @usecase def test(): Int * * This takes the implicit value in scope. * * Example: `test()` * * @usecase def test(explicit: Int): Int * * This takes the explicit value passed. * * Example: `test(3)` */ def test(implicit lost: Int): Int
* | Merge remote-tracking branch 'soc/scaladoc-spacing' into developPaul Phillips2011-12-061-4/+3
|\ \
| * | Fixes the annoying spaces between name, type params and params in ScalaDoc.Simon Ochsenreither2011-12-061-4/+3
| | |
* | | Fix documentation stutters.Blair Zajac2011-12-069-9/+9
| |/ |/|
| |
| \
*-. \ Merge remote-tracking branches 'kepler/topic/dumpclasses' and ↵Paul Phillips2011-12-053-3/+25
|\ \ \ | | | | | | | | | | | | | | | | | | | | 'joshmarcus/collections_docs' into develop Closes SI-5280.
| * | | -Ydump-classes: the option to dump the generated bytecodeluajalla2011-12-053-3/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -Ydump-classes option is intended to dump the compiler generated bytecode to the .class files in given directory. It can be pretty useful for reflective compilation that utilizes in-memory classloaders, for example to check the files if compiler produces invalid bytecode. In this case the dump helps to understand what exactly is wrong with the emitted class. The option format is -Ydump-classes <dir>.
| | | |
| \ \ \
*-. \ \ \ Merge remote-tracking branches 'kepler/topic/reifycopypaste' and ↵Paul Phillips2011-12-051-1/+1
|\ \ \ \ \ | |_|_|/ / |/| | | | | | | | | 'kepler/topic/reifytests' into develop
| * | | | A minor fix to -Yreify-copypaste.Eugene Burmako2011-12-051-1/+1
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | Empty modifiers are now correctly printed out as "Modifiers()" instead of annoyingly verbose "Modifiers(Set(), newTermName(""), List())". No review.
* | | | Don't generate redundant interfaces.Paul Phillips2011-12-051-1/+13
| | | | | | | | | | | | | | | | | | | | Dropped redundant parents during bytecode generation to ease trouble on android. Closes SI-5278.
* | | | Fix path mangling for 'scala' shell script on MinGW/MSYS.Stefan Zeiger2011-12-051-5/+17
|/ / /
| | |
| \ \
*-. \ \ Merge remote-tracking branches 'kepler/topic/reifyclasses' and ↵Paul Phillips2011-12-044-2/+16
|\ \ \ \ | | | | | | | | | | | | | | | 'ijuma/feature/signum' into develop
| * | | | Reification of classes now produces trees that can be compiled and run.Eugene Burmako2011-12-044-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Multiple minor fixes to Martin's implementation of reflection infrastructure. Dominating theme is allowing for the fact that compilation via reflection involves numerous exports/imports between various reflection universes. Fixes SI-5230. Review by @odersky.
* | | | | Tweaked ident suggestions.Paul Phillips2011-12-043-18/+16
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | Rolled damaru-levenshtein algorithm back to my original "pure" version. Cut max distance to 1. Turned on by default because now it offers nothing unexpected, and removed short-lived -Ysuggest-idents option.
* | | | Added -Ysuggest-idents.Paul Phillips2011-12-034-15/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Suggest possible alternatives when an identifier is not in scope. % scala -Ysuggest-idents scala> import scala.collection.mutable._ import scala.collection.mutable._ scala> new MistBuffer <console>:11: error: not found: type MistBuffer (similar: ListBuffer, Buffer) new MistBuffer ^ Too bad, no MistBuffer. We'll settle for ListBuffer.
* | | | Eliminated redundant error message.Paul Phillips2011-12-031-5/+3
|/ / / | | | | | | | | | | | | No secondary "reassignment to val" for unknown identifiers in assignment position.
* | | Revert "Fixes the annoying spaces between name, type params and params in ↵Paul Phillips2011-12-021-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | ScalaDoc." This reverts commit 086b558f2d025323c86226b2560578c50ee48b84. It causes two scaladoc tests to fail; the scaladoc tests are almost completely opaque and I have no time to reverse engineer them.
* | | Fixes the annoying spaces between name, type params and params in ScalaDoc.Simon Ochsenreither2011-12-021-4/+3
| |/ |/|