| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| | |
further polishing of reflection
|
| |
| |
| |
| |
| | |
I think `isVal` and `isVar` are the right names, because they
exactly map on Scala syntax.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As discussed, this is not the best API to expose, because this is an
implementation detail that might change.
However the ship has sailed. We're already imposing
the moduleClass <-> sourceModule quirk to the users of our API:
Evidence: http://stackoverflow.com/questions/12128783.
There are reflection tasks that cannot be pulled without the knowledge
of this implementation detail, so we shouldn't pretend that we can
change it on a whim and not break anything.
Hence I propose to add sourceModule to the public contract
and bear the potential consequences.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Symbol.pos is moved to macros.Universe, because it's empty at runtime.
Also added Symbol.associatedFile, because it has valid usages during runtime.
When reflecting one might want to get to a classfile of the symbol and then
analyze it to e.g. decompile the bytecode or find out the associated src file.
|
| |
| |
| |
| |
| | |
no longer necessary, since scala.tools.nsc.io.AbstractFile
has been long moved to scala-reflect.jar
|
| |
| |
| |
| | |
Doesn't seem to be inferrable from the API we expose right now
|
| | |
|
| |
| |
| |
| | |
Doesn't seem to be inferrable from the API we expose right now
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Sure this stuff is also declared in Type.baseClasses, but this is
one of the hot paths in reflection (e.g. like ClassSymbol.typeParams),
so I think it's justified to have it as a dedicated method.
Unfortunately we cannot remove Type.baseClasses, because it includes
ridiculously involved calculation of base classes for compound types.
|
| |
| |
| |
| | |
As requested in http://stackoverflow.com/questions/12078366/
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When an error occurs because some type does not conform
to AnyRef (and an AnyRef-derived type would have sufficed)
try to say something useful about the situation.
This commit also initializes scope members before printing
error messages because the + version seems more useful than
the - version (taken from one of the checkfile diffs.)
- def <init>: <?>
- def methodIntIntInt: <?>
+ def <init>(): X
+ def methodIntIntInt(x: scala.Int,y: scala.Int): scala.Int
|
| |
| |
| |
| |
| |
| |
| |
| | |
My summary in the ticket was incorrect. The problem was that the
class type parameters were being cloned for the method and being
allowed to keep their variance. I threw in an assertion for anyone
attempting to create a method type with variant type parameters,
because hey, why should we allow such madness.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This pull request applies some tuning changes to the reflection library:
1) the traits scala.reflect.api.FlagSets, scala.reflect.api.Mirrors
and scala.reflect.internal.Importers extend their corresponding
trait in the base layer of the cake.
2) method isType and asType in trait TypeSymbolBase is declared final
3) small changes in the docs.
|
|/
|
|
|
|
|
|
|
|
|
|
|
| |
use Universe.showRaw instead:
scala> import scala.reflect.runtime.{universe => ru}
import scala.reflect.runtime.{universe=>ru}
scala> ru.showRaw(typeOf[Int])
res0: String = TypeRef(ThisType(scala), scala.Int, List())
scala> ru.showRaw(typeOf[Int].typeSymbol, printKinds = true)
res1: String = scala.Int#CLS
|
|\
| |
| | |
adds weak_<:< to the API
|
| |
| |
| |
| |
| | |
quite a fundamental method to be left to be implemented manually
by the users of the reflection API
|
|\ \
| | |
| | | |
exposes overridenSymbol/overridingSymbol in API
|
| |/
| |
| |
| | |
it seems like we completely overlooked this functionality
|
|/
|
|
|
|
|
| |
to be symmetric with typeTag and typeOf.
this is especially important for macro development,
since only c.AbsTypeTag context bounds can be used on macro implementations
|
|
|
|
| |
All statistics code is now subject to a switch at each use site, as opposed to a compile-time constant before. We should veryfy that this does not affect performance. Statistics is a useful ability to have for trouble-shooting compile time speeds on specific code bases. But we should not pay a lot for having it on normal runs.
|
|
|
|
|
|
| |
If our theory wrt map is correct (i.e. that it gets inlined by JVM), then closure hoisting is counter-productive because it migh well prevent the closure from being inlined. This commit removes all hoisted closures that are passed to map and leaves only those boolean closures that are passed to exists and forall.
I should have split the early optimizations including closures into separate commits. As that train has left, I am now reverting some bits to see whether the reverts affect performance at all, and in what direction.
|
| |
|
| |
|
|
|
|
| |
Profile data actually showed a small slowdown in steady state. We keep the reordering but merge all submethods into one.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Inline `UndoLog.undoUnless` into `isSubType`
and `isSameType` methods. They are responsible
for 20% of all Function0 allocations.
I had to do manual inlining because inlier
doesn't cope with exception handlers well.
Let it be noted that I almost cried while doing
this ugly change. I'll want to see inliner
being fixed so we can revert this change ASAP.
|
|
|
|
|
|
|
| |
Two optimizations:
(1) Make SymTree a class rather than a trait to allow faster access to symbol
(2) Split itransform into several smaller methods and order cases according to expected frequency.
|
| |
|
|
|
|
|
|
|
|
|
| |
Introduced explicit locking mechanism that allows us to
make public methods of `UndoLog` that take thunks as
arguments final and thus `@inline`. Once inliner is able
to cope with inlining methods with exception handlers
we'll be able to get rid of significant (around 5%)
number of thunk allocation.
|
|
|
|
|
| |
Those two methods contribute 2% of Function0 allocation
when compiling `Vector.scala`.
|
|
|
|
| |
Driven by profile data.
|
|
|
|
|
|
|
|
|
| |
profiling data shows that accessing the hashCode field has a cost of about 10% of fully hot running times. We speculate that it's megamorphic dispatch which is costing us this much.
Rewrote code so that UniqueType is not an abstract base class with the hashCode field.
Also removed fingerPrinting bloom filter on findMember because it caused complexity and did not gain us anything accdoring to the tests.
Made TypeVar an abstract case class to avoid extractor calls in TypeMap.
|
|
|
|
| |
now the same and faster.
|
| |
|
| |
|
|
|
|
|
| |
Also avoided systematically to map (_.tpe) on parameters in favor of
lazy val paramTypes.
|
|
|
|
|
|
|
|
|
|
|
|
| |
It turns out that exists is not inlinable, even if put into List.
We try to eliminate or hoist most closures passed to exists in Types.
There are some other small improvements as well.
--
(@gkossakowski): This commit contains also a fix to crasher
prepared by @paulp. I squashed that commit and kept the
test-case that came with it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Error reporting is moved to ContextErrors to disentangle stuff in Macros.scala.
With logics and error reporting intertwined it was an awful mess.
Exceptions are used for the same reason. Instead of threading failures through
the code polluting it with options/ifs, I outline the success path.
It worked much better for typedMacroBody, but I'm also happy with the resulting
code of macroExpand. To me a major factor towards applicability of exceptions
was that they are short-lived and that there might be max one error per domain,
after which we unconditionally bail.
|
|\
| |
| | |
more cleanup in Macros.scala
|
| | |
|
| | |
|
|\ \
| | |
| | | |
Topic/substmap210
|
| |/
| |
| |
| |
| |
| |
| |
| | |
Don't create a new type with the same symbol. This
modification avoids the creation of 30K types and a
similar number of symbols in a compile of trunk.
Also cleaned up / deprecated a couple other type mappers.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
With this commit, the number of :: allocations logged in total
after individually compiling each scala file in src/compiler
drops from 190,766,642 to 170,679,925. Twenty million fewer
colon-colons in the world, it's a start.
For some heavily used lists like List(List()) I made vals so
we can reuse the same one every time, e.g.
val ListOfNil = List(Nil)
The modifications in this patch were informed by logging call
frequency to List.apply and examining the heaviest users.
>> Origins tag 'listApply' logged 3041128 calls from 318 distinguished sources.
1497759 scala.reflect.internal.Definitions$ValueClassDefinitions$class.ScalaValueClasses(Definitions.scala:149)
173737 scala.reflect.internal.Symbols$Symbol.alternatives(Symbols.scala:1525)
148642 scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:306)
141676 scala.tools.nsc.transform.SpecializeTypes$$anonfun$scala$tools$nsc$transform$SpecializeTypes$$specializedOn$3.apply(SpecializeTypes.scala:114)
69049 scala.tools.nsc.transform.LazyVals$LazyValues$$anonfun$1.apply(LazyVals.scala:79)
62854 scala.tools.nsc.transform.SpecializeTypes.specializedTypeVars(SpecializeTypes.scala:427)
54781 scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:293)
54486 scala.reflect.internal.Symbols$Symbol.newSyntheticValueParams(Symbols.scala:334)
53843 scala.tools.nsc.backend.icode.Opcodes$opcodes$CZJUMP.<init>(Opcodes.scala:562)
... etc.
|
|\
| |
| | |
cleanup of reflection and macros
|
| | |
|
| |
| |
| |
| |
| |
| | |
mostly removes [Eugene] marks that I left back then and reviews related code
some of those tokens got left in place, because I don't know to how fix them
without imposing risks on 2.10.0
|
|\ \
| |/
|/| |
Introduces the `isArtifact` test for symbols
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This test is necessary in the API to tell apart useful synthetic symbols
(such as accessors) and low-level compilation artifacts (such as $outer).
However `isHidden` (as it's currently named in the compiler) is too generic.
Hence I renamed it along with the corresponding flag. Now the test says
`isArtifact` and the flag is named ARTIFACT.
Despite being an improvement over the first version, `isArtifact` is
still a bit unlucky. The name I like is `isImplementationArtifact`, but that's
a mouthful to be used in compiler hacking. Moreover, IMPLEMENTATION_ARTIFACT
looks weird.
For a discussion about related stuff see:
http://groups.google.com/group/scala-internals/browse_thread/thread/d04e762127737968
https://github.com/scala/scala/pull/1114
|
|\ \
| | |
| | | |
SI-5940 impls are no longer in macro def pickles
|