-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Issue for myself based on reading the code and modifying it for the optimizer.
These may or may not be good ideas.
- We have a whole hierarchy of class/method/labelnode just to keep 1 bit of info per label, whether it's reachable or not. Surely we can use a WeakHashSet or similar? (Or even just a HashSet if the lifetimes work out?)
- Most of the utility classes appear to be historical accident and could be split better
- AsmUtils in particular is all about logging
- DottyBackendInterface should not exist
- Aggressively move stateless stuff out of stateful classes
- instead of a big switch to map bytecode versions we can do integer addition...
- Do we really need all the BType creation stuff in CoreBTypesFromSymbols, or could we do comparisons on Java type descriptors for instance?
- CoreBTypes in general seems like it should be named WellKnownBTypes or similar
- Why does the stuff in BTypes need to be in there rather than top-level or somewhere else? Especially inliner stuff
- CallGraph should not let other classes touch its internals, and more generally we should have clearer boundaries around classes
- grep --include=*.scala -Fr '.jvm' compiler | grep -Fv '/jvm'` should return nothing
- simplify emitting supercalls to not need to add explicit inheritance Simplify JVM interface list emission, remove a mini-phase #25203 (comment)
More notes about that last point:
compiler/test/dotty/tools/dotc/classpath/MultiReleaseJarTest.scala:class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
Good indication DottyBytecodeTest should be moved up the hierarchy?
compiler/test/dotty/tools/dotc/classpath/JrtClassPathTest.scala:import dotty.tools.backend.jvm.AsmUtils
Can be inlined, extremely basic use of ClassReader
compiler/test/dotty/tools/dotc/ConstantFoldingTests.scala:import dotty.tools.backend.jvm._
Another use of DottyBytecodeTest (it's an e2e constant folding, not bad)
compiler/test/dotty/tools/dotc/transform/SpecializeTuplesTests.scala:import dotty.tools.backend.jvm.DottyBytecodeTest
compiler/test/dotty/tools/dotc/transform/SpecializeFunctionsTests.scala:import dotty.tools.backend.jvm.DottyBytecodeTest
More DottyBytecodeTest
compiler/src/dotty/tools/dotc/core/Phases.scala:import dotty.tools.backend.jvm.GenBCode
Exposes genBCodePhase to:
- CollectEntryPoints -> removed in PR
- CollectSuperCalls -> removed in PR
- GeneratedClassHandler -> as part of ThreadPoolFactory creation, for logging purposes
-> Could be a String
-> This is the only creation of ThreadPoolFactory in the entire compiler anyway!
- GenericSignatures which does "atPhase(genBCodePhase) { sanitizeName(sym.fullName).replace('.', '/') }" -> why?
- TreeChecker uses it in "isNonMagicalMember" which sounds worrying
compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala:import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions
.javaClassName
compiler/src/dotty/tools/dotc/config/ScalaSettingsProperties.scala:import dotty.tools.backend.jvm.BackendUtils.classfileVersionMap
that property should probably be moved somewhere else?
also, it can be computed instead of being a map, so we could instead code just the min/max instead of having to depend on a map
compiler/src/dotty/tools/dotc/Compiler.scala:import backend.jvm.{CollectSuperCalls, GenBCode}
OK, Compiler referencing a Phase
compiler/src/dotty/tools/dotc/profile/Profiler.scala:import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions
.javaBinaryName
compiler/src/dotty/tools/dotc/transform/CollectEntryPoints.scala:import dotty.tools.backend.jvm.GenBCode
See remark on Phases above
compiler/src/dotty/tools/dotc/transform/TreeChecker.scala:import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions
See remark on Phases above
compiler/src/dotty/tools/backend/sjs/JSPrimitives.scala:import dotty.tools.backend.jvm.DottyPrimitives
Should rename DottyPrimitives to ScalaPrimitives and move it next to ScalaPrimitiveOps in backend/
compiler/src/dotty/tools/backend/sjs/JSEncoding.scala:import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions
.javaSimpleName
.javaClassName
compiler/src/dotty/tools/debug/JavaEncoding.scala:import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions
.javaClassName
Reactions are currently unavailable