Skip to content

Call graph with DCE #1840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 345 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
345 commits
Select commit Hold shift + click to select a range
23e5b8b
Add calls to unapply.
Roldak Nov 23, 2016
6b2c7aa
Fix to be able to run `sbt test`
nicolasstucki Nov 23, 2016
3c2625a
Add CG tests for code called from java.
nicolasstucki Nov 26, 2016
df9f357
Fix CG calls from java code.
nicolasstucki Nov 27, 2016
de0ece4
Rename @export to @EntryPoint and add reachability assertions.
nicolasstucki Nov 28, 2016
6f64655
Fix CG entry point module initialization.
nicolasstucki Nov 28, 2016
cbe24e3
Add message to DeadCodeEliminated when call with reflection.
nicolasstucki Nov 28, 2016
94be47a
Refactor code haneling calls from java.
nicolasstucki Nov 28, 2016
01e17dc
Add back CG diagnostic output
nicolasstucki Nov 29, 2016
59ae728
Fix CG call to mixin constructors.
nicolasstucki Nov 29, 2016
826a0e6
Fix CG vis for calls with source.
nicolasstucki Nov 29, 2016
451e772
Fix CG fillinStackTrace for BreakControl.
nicolasstucki Nov 29, 2016
cb3f5bb
Reenable pattern match test.
nicolasstucki Nov 29, 2016
ecd45e7
Fix issue with JavaAllocatedTypes.
nicolasstucki Nov 29, 2016
b2082f0
Fix HKApply in JavaAllocatedTypes.
nicolasstucki Nov 29, 2016
5ebf86c
Compile more CG tests with stdlib.
nicolasstucki Nov 29, 2016
27167ce
Replace nullable references with optional references.
nicolasstucki Nov 30, 2016
c3cc3c6
Cleanup OuterTargs.
nicolasstucki Nov 30, 2016
c934e7a
Add more assetrions to JavaAllocatedTypes
nicolasstucki Nov 30, 2016
4f5c815
Move clases and rename them.
nicolasstucki Nov 30, 2016
ff96bc2
Add test for break.
nicolasstucki Nov 30, 2016
4432c3d
Handle patterns in try catch
Roldak Nov 30, 2016
82f5bb2
Add test for try catch unapply
Roldak Dec 1, 2016
3e6737c
Fix CG issue with PolyParams in JavaAllocatedTypes.
nicolasstucki Dec 1, 2016
8a0f62a
Normilize DCE tests folder names
nicolasstucki Dec 2, 2016
d1c99ed
Enable DCE test that does not fail anymore.
nicolasstucki Dec 2, 2016
877a143
Add assertions in CG.
nicolasstucki Dec 2, 2016
a909c1a
Remove second DeadCodeElimination miniphase.
nicolasstucki Dec 4, 2016
1456fc1
Fix double collection of method summaries.
nicolasstucki Dec 4, 2016
351e50d
Abstract over CallInfo and CallInfoWithContext.
nicolasstucki Dec 6, 2016
6a9c552
Make MethodSummary immutable and add MethodSummaryBuilder.
nicolasstucki Dec 6, 2016
0864256
Enable CG tests.
nicolasstucki Dec 7, 2016
0eaf148
Add CG failing tests.
nicolasstucki Dec 7, 2016
b4db4cd
Add two failing tests (lambdas and inner objects)
Roldak Dec 3, 2016
0670a04
Add failing test with lazy vals
Roldak Dec 4, 2016
8d58862
Fix local lazy val's accessors being DCEd
Roldak Dec 4, 2016
6d5f7a3
Fix closures in CG
Roldak Dec 4, 2016
05379b8
Fix CG visualization for lambdas
Roldak Dec 4, 2016
13831a4
Add lambda test
Roldak Dec 4, 2016
661c8fd
Fix issues with rebasing
Roldak Dec 4, 2016
d956955
Put back tests.
nicolasstucki Dec 8, 2016
40800d9
Fix CollectSummaries.
nicolasstucki Dec 8, 2016
2d8a623
Remove context from CallInfos.
nicolasstucki Dec 9, 2016
19f5c85
Extract cast cache from TypeWithContext
nicolasstucki Dec 9, 2016
1a67558
Add dotty library files to CG tests.
nicolasstucki Dec 9, 2016
9eccbfc
Display more information in CG visualization.
nicolasstucki Dec 10, 2016
38d6070
Fix SubstituteByParentMap on HKApply.
nicolasstucki Dec 12, 2016
c69d800
Fix CG partest.
nicolasstucki Dec 13, 2016
4d4fb15
Add overrieds in tests to workarround common issues.
nicolasstucki Dec 13, 2016
010d13c
Make CG tests override more fine grained.
nicolasstucki Dec 19, 2016
03e959f
Remove code from DeadCodeEliminated as it becomes DCEed.
nicolasstucki Dec 19, 2016
eee5fcd
Add checks
nicolasstucki Dec 19, 2016
0509434
Partially enable CG tests.
nicolasstucki Dec 19, 2016
a3fb530
Update CG tests.
nicolasstucki Dec 19, 2016
d693045
Check CallInfo assertions on instantiation.
nicolasstucki Dec 19, 2016
8acf5b9
Split stdlib tests
nicolasstucki Dec 20, 2016
d68f0dd
Fixes after rebase.
nicolasstucki Dec 20, 2016
5635984
Limit partest paralelism
nicolasstucki Dec 20, 2016
02218b2
Fix unapply in CG.
nicolasstucki Dec 21, 2016
7b5350f
Unify stdlib lists and re-enable checks.
nicolasstucki Dec 21, 2016
7d98724
Add failing test with closure defined in a generic context
nicolasstucki Dec 22, 2016
dd7120a
Fix closures being DCEd when defined in a generic context
Roldak Dec 21, 2016
4409554
Fix unapply calls, replaces nme.isDefined by nme.isEmpty
Roldak Dec 21, 2016
d7d1ab8
Refactor handling of reachable closures
Roldak Dec 21, 2016
85ac847
Add second, failing test with closures in generic context
Roldak Dec 21, 2016
db9ab8a
Add drone timeout.
nicolasstucki Dec 22, 2016
518f010
Fix calls to java methods with type bounds.
nicolasstucki Dec 23, 2016
12fb96a
Re enable entry point tests.
nicolasstucki Jan 3, 2017
8961313
Remove workaround for issue #1878.
nicolasstucki Jan 5, 2017
e551709
Remove workarounds for fixed stdlib files.
nicolasstucki Jan 5, 2017
beb3d6e
Disable tests.
nicolasstucki Jan 5, 2017
2fbbca4
Add test
nicolasstucki Jan 6, 2017
5670ce3
Fix CG mixin init with type parameter.
nicolasstucki Jan 9, 2017
11e3d97
Fix CG vis output filename.
nicolasstucki Jan 9, 2017
3eccb6a
Remove empty package from entry points init.
nicolasstucki Jan 9, 2017
8aca75c
Add tests and cleanup overwrites.
nicolasstucki Jan 9, 2017
2b6b153
Fix CG Predef module load.
nicolasstucki Jan 10, 2017
06a9a8e
Add missing flags for stdlib CG tests
nicolasstucki Jan 11, 2017
b165ea3
Fix CallInfoWithContext equality and add this to java methods.
nicolasstucki Jan 11, 2017
162eba3
Remove CG test overwrites.
nicolasstucki Jan 12, 2017
a0b7c82
CG test triage.
nicolasstucki Jan 12, 2017
4507ecb
Tighten CG bound checks.
nicolasstucki Jan 12, 2017
b96bdc4
Fixes after rebase.
nicolasstucki Jan 12, 2017
355aae3
Remove redundant mixin init calls in CG.
nicolasstucki Jan 12, 2017
930a705
Use limited resources for stdlib link tests.
nicolasstucki Jan 12, 2017
467766e
Start fixing tasty CG.
nicolasstucki Jan 13, 2017
66082f7
Fix CG type selection.
nicolasstucki Jan 13, 2017
9b6f6c6
Fix package module syms getting into java calls.
nicolasstucki Jan 13, 2017
3082d4b
Add CG test.
nicolasstucki Jan 13, 2017
732956b
Register all calls from java in call graph.
nicolasstucki Jan 15, 2017
6f120d9
Fix CG vis cycle edges.
nicolasstucki Jan 15, 2017
426021c
Add CG tests for java code.
nicolasstucki Jan 16, 2017
8c960c3
Small improvement on CG vis colors.
nicolasstucki Jan 16, 2017
220919b
Re-enable immutable.HashSet
nicolasstucki Jan 16, 2017
4cb9f54
Fix CG despatch to outer this.
nicolasstucki Jan 17, 2017
0be74e9
Remove while loops from CallGraphBuilder.
nicolasstucki Jan 17, 2017
129ee2d
Refine tests.
nicolasstucki Jan 17, 2017
3acbd38
Fix varargs of refined types.
nicolasstucki Jan 17, 2017
61dd4a5
Remove Enumeration from blacklist.
nicolasstucki Jan 17, 2017
4eaeb1b
Do not add init calls to interfaces.
nicolasstucki Jan 18, 2017
1fcb3b5
Remove java call from java calls.
nicolasstucki Jan 18, 2017
aa2f779
Make call in CallInfoWithContext a TermRef.
nicolasstucki Jan 18, 2017
9b3369c
Fix call selection in casts.
nicolasstucki Jan 18, 2017
9d6e7ef
Sort tests and remove unwanted entry points from stdlib.
nicolasstucki Jan 18, 2017
c51b32c
Tighten bounds.
nicolasstucki Jan 18, 2017
05ac010
Stop expanding java calls.
nicolasstucki Jan 19, 2017
b0e1d7e
Add cast test.
nicolasstucki Jan 19, 2017
9b65596
Fix call selection in casts and type member selection.
nicolasstucki Jan 19, 2017
f4420a4
Fix CG Predef load on methods with type parameters.
nicolasstucki Jan 23, 2017
5403bf4
Fix cyclic reference when bootstraped.
nicolasstucki Feb 20, 2017
e301e28
Fix bootsrtap linker.
nicolasstucki Feb 22, 2017
23c3e5d
Small fix.
nicolasstucki Feb 22, 2017
fe882dd
Unify stdlib tests again.
nicolasstucki Feb 22, 2017
a51e907
Remove old commented code and outdated commnets.
nicolasstucki Feb 22, 2017
5c25215
Fix tests.
nicolasstucki Feb 22, 2017
4733627
Make CallInfoWithContext a normal class.
nicolasstucki Feb 22, 2017
ae5ba78
Fix refined types generated by callgraph.
nicolasstucki Feb 28, 2017
6c25099
Fix inconsistent substitution map.
nicolasstucki Mar 2, 2017
fa38e63
Add flag to compute java callgraph.
nicolasstucki Mar 4, 2017
5444d66
Revert "Don't keep full picklers around until backend."
nicolasstucki Mar 6, 2017
aea0d22
Fix CG for constructor with implicit params.
nicolasstucki Mar 8, 2017
97c0671
Fix some bugs on CG bootstaraped
nicolasstucki Mar 8, 2017
53a8a1e
Remove unnecessary case classes.
nicolasstucki Mar 9, 2017
45e9656
Improve output of calgraph log.
nicolasstucki Mar 9, 2017
729e0e1
Fix precice priveate method calls.
nicolasstucki Mar 13, 2017
85bdd2f
Fix vis
nicolasstucki Mar 13, 2017
baff06b
Remove redundant outer map
nicolasstucki Mar 13, 2017
076e200
Add cache for registerParentModules.
nicolasstucki Mar 14, 2017
b77de93
Remove unused param.
nicolasstucki Mar 14, 2017
75e4b28
Improve getTypesByMemberName
nicolasstucki Mar 14, 2017
4e0d8d9
Refine preciseSelectCall.
nicolasstucki Mar 14, 2017
017852d
Remove WorkList
nicolasstucki Mar 14, 2017
02fe50b
Fix after rebase.
nicolasstucki Mar 15, 2017
03b180b
WIP add guard before instantiateCallSite based on number of reachable…
nicolasstucki Mar 15, 2017
cb96dfe
Add failing test.
nicolasstucki Mar 15, 2017
a7d6c67
Fix on bootstrap.
nicolasstucki Mar 16, 2017
94df0e0
Improve CG log
nicolasstucki Mar 16, 2017
fb9d927
Fix missing calls.
nicolasstucki Mar 16, 2017
f9ea6a9
Add missing casts.
nicolasstucki Mar 16, 2017
05b054c
Remove unused name.
nicolasstucki Mar 16, 2017
3a7a70d
Add link bootstrap sttting.
nicolasstucki Mar 17, 2017
dff9950
CG log
nicolasstucki Mar 17, 2017
8570976
Avoid allocating lists if possible.
nicolasstucki Mar 17, 2017
d96380f
Fix CG termination condition
nicolasstucki Mar 17, 2017
a3e8268
Simplify CallInfoWithContext
nicolasstucki Mar 17, 2017
09631ce
Small code refactor
nicolasstucki Mar 17, 2017
491836c
Impove performance.
nicolasstucki Mar 17, 2017
af670a1
Only add accessed module once.
nicolasstucki Mar 17, 2017
b4cac4b
Add naive type deepness cache.
nicolasstucki Mar 20, 2017
69b1893
Fix issue with crc
nicolasstucki Mar 21, 2017
9f41028
Improve cast depth heuristic
nicolasstucki Mar 21, 2017
3475a2b
Improve dispatchCalls
nicolasstucki Mar 21, 2017
9954e00
Improve memory consumption of graph vis
nicolasstucki Mar 21, 2017
fe71d74
wip on loading from tasty.
nicolasstucki Mar 22, 2017
91f2843
Fix issue with closure in withFilter.
nicolasstucki Mar 22, 2017
32957e4
Add second test case for zipWithIndex.
nicolasstucki Mar 23, 2017
cdb52fb
Add agressive DCE mode
nicolasstucki Mar 23, 2017
11982e6
Aggressive DCE without modifying the type.
nicolasstucki Mar 24, 2017
8b1f45b
Fix closure outer targs.
nicolasstucki Mar 24, 2017
caae33f
Normilize types in CallInfo.
nicolasstucki Mar 24, 2017
a8cdc66
Add all fix done by Vladimir.
nicolasstucki Mar 24, 2017
c2d73b8
Fix aggressive DCE on Arrays
nicolasstucki Mar 27, 2017
40dba68
Buggy test.
nicolasstucki Mar 27, 2017
41dbfc8
Do not capture context in CallInfos
nicolasstucki Mar 27, 2017
f5ce861
Disable non aggressive stdlib DCE
nicolasstucki Mar 27, 2017
dbf0a71
3X improvement on casts.
nicolasstucki Mar 28, 2017
7e05b55
More speedup on casts
nicolasstucki Mar 28, 2017
054ad68
Normilize calls in CallInfoWithContext.
nicolasstucki Mar 28, 2017
0bfb0db
Fix issue with normalization on TermRefWithFixedSym.
nicolasstucki Mar 28, 2017
b298775
Partially fix sizesCache for CRC.
nicolasstucki Mar 28, 2017
2a24eb7
Fix incompleteness on casts.
nicolasstucki Mar 29, 2017
69d0a1b
WIP enable assertions.
nicolasstucki Mar 29, 2017
1e4e149
Quick fix after rebase
nicolasstucki Mar 29, 2017
7864766
Fix NamedArg collected type.
nicolasstucki Mar 30, 2017
fd92bf2
Improve performance.
nicolasstucki Mar 30, 2017
3ccafc3
Adding link tests to new tests.
nicolasstucki Mar 30, 2017
7723b77
Refactor tests.
nicolasstucki Mar 31, 2017
8f535d8
Add link stdlib tests to Compilation tests.
nicolasstucki Mar 31, 2017
201c7bd
Only compute out egdes if needed (in the last iteration).
nicolasstucki Mar 31, 2017
62256be
Improve CG loop log.
nicolasstucki Apr 3, 2017
b914a6c
Set limited resources to link stdlib.
nicolasstucki Apr 3, 2017
4dee266
Remove unnecesarry flatten and flatmaps.
nicolasstucki Apr 3, 2017
4f84b04
Rename paramTypes to paramInfos
nicolasstucki Apr 7, 2017
ddc8a23
Tasty fixes.
nicolasstucki Apr 3, 2017
5d6a975
Disable arggressive DCE tests in new tests.
nicolasstucki Apr 3, 2017
e8a9297
Improve speed of casts.
nicolasstucki Apr 3, 2017
89e737d
WIP add strawman callgraph tests.
nicolasstucki Apr 4, 2017
034df99
Disable strawman tests.
nicolasstucki Apr 5, 2017
2f0a72d
WIP load MethodSummaries from tasty.
nicolasstucki Apr 6, 2017
82934f6
New version of specialization.
DarkDimius Feb 18, 2016
a4a280e
WIP on spec
DarkDimius Mar 7, 2016
2821e6b
WIP
DarkDimius Apr 26, 2016
71e643c
WIP
DarkDimius Apr 30, 2016
eab00d1
WIP
DarkDimius May 4, 2016
986330d
OuterSpecialized: propagate specialization information across clones.
DarkDimius May 8, 2016
72435f5
Fix compilation after cutting out devalify and devirtualization.
DarkDimius May 8, 2016
78f469f
Allow disabling call-graph construction.
DarkDimius May 8, 2016
ac145dd
Shorten the flag values. -lto:specialize -> -lto:spec
DarkDimius May 9, 2016
483813a
Move OuterSpecializer
nicolasstucki Apr 7, 2017
10f1998
Quick fixes to OuterSpecializer
nicolasstucki Apr 7, 2017
3f8d921
Enable strawman tests
nicolasstucki Apr 7, 2017
d14d68c
Rename stdlib dce test folder.
nicolasstucki Apr 7, 2017
ec71256
Add test isfrastructure for link specialization
nicolasstucki Apr 7, 2017
aaec639
Enable sendSpecializationRequests
nicolasstucki Apr 7, 2017
67a3386
Disable OuterSpecializer
nicolasstucki Apr 7, 2017
7826e09
Reenable strawman tests after rebase on fix.
nicolasstucki Apr 10, 2017
cd3f131
Fix stdlib test with inactive OuterSpecializer.
nicolasstucki Apr 10, 2017
764db49
Add workarround scalaShadowing
nicolasstucki Apr 10, 2017
361fa77
Fix first specialization test.
nicolasstucki Apr 10, 2017
8b209f5
Create link test utils.
nicolasstucki Apr 10, 2017
8345e35
Fix EntryPoint args and Tasty reciever flags.
nicolasstucki Apr 11, 2017
273a864
Fixes after rebase.
nicolasstucki Apr 12, 2017
e55e4e0
Cleanup TastySummaries.
nicolasstucki Apr 12, 2017
41f0b31
Merge remote-tracking branch 'dotty/master' into call-graph-wip-1
nicolasstucki Apr 12, 2017
4175d0c
Combine DCE tests for test parallelism.
nicolasstucki Apr 12, 2017
eee967b
Merge remote-tracking branch 'dotty/master' into call-graph-wip-1
nicolasstucki Apr 20, 2017
b8cfce5
Remove commented debug println.
nicolasstucki Apr 20, 2017
eba3568
Code cleanup.
nicolasstucki Apr 20, 2017
9bee81f
Remove custom submodule update.
nicolasstucki Apr 20, 2017
013bba0
Add test.
nicolasstucki Apr 20, 2017
4e6a21a
Merge remote-tracking branch 'dotty/master' into call-graph-wip-1
nicolasstucki Apr 20, 2017
203e2a7
Remove redundant stdlib DCE tests.
nicolasstucki Apr 20, 2017
8b51c78
Fix DCE stdlib test overrides.
nicolasstucki Apr 20, 2017
e42e177
Refactoring.
nicolasstucki Apr 20, 2017
6d485de
Remove ctx from summaries unplickler
nicolasstucki Apr 20, 2017
c9a889c
Move summary unplickeler.
nicolasstucki Apr 24, 2017
6eac83a
Merge remote-tracking branch 'dotty/master' into call-graph-wip-1
nicolasstucki Apr 24, 2017
39ccbe3
Merge remote-tracking branch 'dotty/master' into call-graph-wip-1
nicolasstucki May 1, 2017
ec2deec
Contain TreeUnpickler leaks.
nicolasstucki May 1, 2017
3e9d76e
Load compilation units when needed based on callgraph.
nicolasstucki May 1, 2017
86392ce
Merge remote-tracking branch 'dotty/master' into call-graph-wip-1
nicolasstucki May 2, 2017
0a2bdc2
Fix CG trait overrites after merge.
nicolasstucki May 2, 2017
908149e
Merge remote-tracking branch 'dotty/master' into call-graph-wip-1
nicolasstucki May 3, 2017
bf71854
Workaround bug with lazy val in object.
nicolasstucki May 3, 2017
f76ce19
Code cleanup.
nicolasstucki May 3, 2017
082aa49
Drop legacy callgraph tests.
nicolasstucki May 3, 2017
005e5d8
Cleanup
nicolasstucki May 3, 2017
b3d79ac
Remove unnecessary change.
nicolasstucki May 3, 2017
a16d28c
Add log on compilation unit loaded.
nicolasstucki May 5, 2017
a07547f
Compile link tests libraries separately.
nicolasstucki May 5, 2017
bc2c675
Merge remote-tracking branch 'dotty/master' into call-graph-wip-1
nicolasstucki May 5, 2017
21f8732
Disable strawman specialize tests.
nicolasstucki May 5, 2017
b56f7cf
Put all link tests in tests/link
nicolasstucki May 5, 2017
c4bafda
Merge remote-tracking branch 'dotty/master' into call-graph-wip-1
nicolasstucki May 8, 2017
7e53968
Merge remote-tracking branch 'dotty/master' into call-graph-wip-1
nicolasstucki May 8, 2017
b329646
Merge remote-tracking branch 'dotty/master' into call-graph-wip-1
nicolasstucki May 29, 2017
789f205
Blacklist link-zipWithIndex-1
nicolasstucki May 29, 2017
a0c5350
Remove SpecializeUtils
nicolasstucki May 29, 2017
ccfd92d
Merge remote-tracking branch 'dotty/master' into call-graph-wip-1
nicolasstucki May 31, 2017
ded07d7
Merge remote-tracking branch 'dotty/master' into call-graph-wip-1
nicolasstucki Jun 8, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/backend/jvm/GenBCode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
val plainC = pcb.cnode

if (claszSymbol.isClass) // @DarkDimius is this test needed here?
for (binary <- ctx.compilationUnit.pickled.get(claszSymbol.asClass)) {
for (pickler <- ctx.compilationUnit.picklers.get(claszSymbol.asClass)) {
val binary = pickler.assembleParts()
val dataAttr = new CustomAttr(nme.TASTYATTR.mangledString, binary)
val store = if (mirrorC ne null) mirrorC else plainC
store.visitAttribute(dataAttr)
Expand Down
10 changes: 8 additions & 2 deletions compiler/src/dotty/tools/dotc/CompilationUnit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ class CompilationUnit(val source: SourceFile) {

def isJava = source.file.name.endsWith(".java")

/** Pickled TASTY binaries, indexed by class. */
var pickled: Map[ClassSymbol, Array[Byte]] = Map()
/**
* Picklers used to create TASTY sections, indexed by toplevel class to which they belong.
* Sections: Header, ASTs and Positions are populated by `pickler` phase.
* Subsequent phases can add new sections.
*/
var picklers: Map[ClassSymbol, TastyPickler] = Map()

var unpicklers: Map[ClassSymbol, TastyUnpickler] = Map()
}
9 changes: 8 additions & 1 deletion compiler/src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Phases.Phase
import transform._
import util.FreshNameCreator
import transform.TreeTransforms.{TreeTransform, TreeTransformer}
import transform.linker._
import core.DenotTransformers.DenotTransformer
import core.Denotations.SingleDenotation

Expand Down Expand Up @@ -47,6 +48,8 @@ class Compiler {
List(new PostTyper), // Additional checks and cleanups after type checking
List(new sbt.ExtractAPI), // Sends a representation of the API of classes to sbt via callbacks
List(new Pickler), // Generate TASTY info
List(new CollectSummaries), // Collects method summaries for the call graph construction
List(new BuildCallGraph), // Builds the call graph
List(new FirstTransform, // Some transformations to put trees into a canonical form
new CheckReentrant, // Internal use only: Check that compiled program has no data races involving global vars
new ElimJavaPackages), // Eliminate syntactic references to Java packages
Expand All @@ -69,6 +72,8 @@ class Compiler {
new ShortcutImplicits, // Allow implicit functions without creating closures
new CrossCastAnd, // Normalize selections involving intersection types.
new Splitter), // Expand selections involving union types into conditionals
List(new OuterSpecializer),
List(new OuterSpecializeParents),
List(new VCInlineMethods, // Inlines calls to value class methods
new IsInstanceOfEvaluator, // Issues warnings when unreachable statements are present in match/if expressions
new SeqLiterals, // Express vararg arguments as arrays
Expand All @@ -82,7 +87,7 @@ class Compiler {
new FunctionXXLForwarders, // Add forwarders for FunctionXXL apply method
new ArrayConstructors), // Intercept creation of (non-generic) arrays and intrinsify.
List(new Erasure), // Rewrite types to JVM model, erasing all type parameters, abstract types and refinements.
List(new ElimErasedValueType, // Expand erased value types to their underlying implmementation types
List(new ElimErasedValueType, // Expand erased value types to their underlying implementation types
new VCElideAllocations, // Peep-hole optimization to eliminate unnecessary value class allocations
new Mixin, // Expand trait fields and trait initializers
new LazyVals, // Expand lazy vals
Expand All @@ -94,6 +99,8 @@ class Compiler {
// Note: constructors changes decls in transformTemplate, no InfoTransformers should be added after it
new FunctionalInterfaces, // Rewrites closures to implement @specialized types of Functions.
new GetClass, // Rewrites getClass calls on primitive types.
new CallGraphChecks,
new DeadCodeElimination, // Replaces dead code by a `throw new DeadCodeEliminated`
new Simplify), // Perform local optimizations, simplified versions of what linker does.
List(new LambdaLift, // Lifts out nested functions to class scope, storing free variables in environments
// Note: in this mini-phase block scopes are incorrect. No phases that rely on scopes should be here
Expand Down
11 changes: 10 additions & 1 deletion compiler/src/dotty/tools/dotc/FromTasty.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import util._
import reporting.Reporter
import Decorators._
import dotty.tools.dotc.transform.Pickler
import tasty.DottyUnpickler
import tasty.{DottyUnpickler, TastyBuffer}
import ast.tpd._
import NameKinds.QualifiedName

Expand Down Expand Up @@ -101,4 +101,13 @@ object FromTasty extends Driver {
}
}
}

def compilationUnit(clsd: ClassDenotation, unpickler: DottyUnpickler)(implicit ctx: Context): CompilationUnit = {
val List(unpickled) = unpickler.body(ctx.addMode(Mode.ReadPositions))
val unit1 = new CompilationUnit(new SourceFile(clsd.symbol.sourceFile, Seq()))
unit1.tpdTree = unpickled
unit1.unpicklers += (clsd.classSymbol -> unpickler.unpickler)
force.traverse(unit1.tpdTree)
unit1
}
}
9 changes: 9 additions & 0 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class ScalaSettings extends Settings.SettingGroup {
val rewrite = OptionSetting[Rewrites]("-rewrite", "When used in conjunction with -language:Scala2 rewrites sources to migrate to new syntax")
val silentWarnings = BooleanSetting("-nowarn", "Silence all warnings.")

val linkDCE = BooleanSetting("-link-dce", "Enable dead code elimination.")
val linkDCEAggressive = BooleanSetting("-link-aggressive-dce", "Enable aggressive dead code elimination.")
val linkVis = BooleanSetting("-link-vis", "Output the visual representation of the call graph.")
val linkJavaConservative = BooleanSetting("-link-java-conservative", "Compute call graph for java methods.")
val linkSpecialize = BooleanSetting("-link-specialize", "Enable link time specialization.")

/** -X "Advanced" settings
*/
val Xhelp = BooleanSetting("-X", "Print a synopsis of advanced options.")
Expand Down Expand Up @@ -105,6 +111,9 @@ class ScalaSettings extends Settings.SettingGroup {
val YnoDoubleBindings = BooleanSetting("-Yno-double-bindings", "Assert no namedtype is bound twice (should be enabled only if program is error-free).")
val YshowVarBounds = BooleanSetting("-Yshow-var-bounds", "Print type variables with their bounds")
val YnoInline = BooleanSetting("-Yno-inline", "Suppress inlining.")
val YlinkDCEChecks = BooleanSetting("-Ylink-dce-checks", "Check number of reachable classes and methods.")
val YlinkSpecialize = IntSetting("-YlinkSpecialize","Specialize methods with maximum this amount of polymorphic types.", 0, 0 to 10)


/** Linker specific flags */
val optimise = BooleanSetting("-optimise", "Generates faster bytecode by applying optimisations to the program") withAbbreviation "-optimize"
Expand Down
12 changes: 11 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ class Definitions {
def DottyArraysModule(implicit ctx: Context) = DottyArraysModuleRef.symbol
def newGenericArrayMethod(implicit ctx: Context) = DottyArraysModule.requiredMethod("newGenericArray")
def newArrayMethod(implicit ctx: Context) = DottyArraysModule.requiredMethod("newArray")
def DottyArraysMethods(implicit ctx: Context) = List(newArrayMethod, newGenericArrayMethod)


lazy val NilModuleRef = ctx.requiredModuleRef("scala.collection.immutable.Nil")
def NilModule(implicit ctx: Context) = NilModuleRef.symbol
Expand Down Expand Up @@ -388,7 +390,7 @@ class Definitions {
def ArrayConstructor(implicit ctx: Context) = ArrayConstructorR.symbol
lazy val ArrayModuleType = ctx.requiredModuleRef("scala.Array")
def ArrayModule(implicit ctx: Context) = ArrayModuleType.symbol.moduleClass.asClass

def ArrayMethods(implicit ctx: Context) = List(Array_apply, Array_update, Array_length, Array_clone, ArrayConstructor)

lazy val UnitType: TypeRef = valueTypeRef("scala.Unit", BoxedUnitType, java.lang.Void.TYPE, UnitEnc)
def UnitClass(implicit ctx: Context) = UnitType.symbol.asClass
Expand Down Expand Up @@ -458,6 +460,12 @@ class Definitions {

def BoxedUnit_UNIT(implicit ctx: Context) = BoxedUnitClass.linkedClass.requiredValue("UNIT")


def isPrimitiveClass(sym: Symbol): Boolean = {
sym == defn.IntClass || sym == defn.LongClass || sym == defn.ShortClass || sym == defn.CharClass || sym == defn.ByteClass ||
sym == defn.BooleanClass || sym == defn.FloatClass || sym == defn.DoubleClass || sym == defn.UnitClass
}

lazy val BoxedBooleanType: TypeRef = ctx.requiredClassRef("java.lang.Boolean")
def BoxedBooleanClass(implicit ctx: Context) = BoxedBooleanType.symbol.asClass
lazy val BoxedByteType: TypeRef = ctx.requiredClassRef("java.lang.Byte")
Expand Down Expand Up @@ -600,6 +608,8 @@ class Definitions {
def ContravariantBetweenAnnot(implicit ctx: Context) = ContravariantBetweenAnnotType.symbol.asClass
lazy val DeprecatedAnnotType = ctx.requiredClassRef("scala.deprecated")
def DeprecatedAnnot(implicit ctx: Context) = DeprecatedAnnotType.symbol.asClass
lazy val EntryPointAnnotType = ctx.requiredClassRef("scala.EntryPoint")
def EntryPointAnnot(implicit ctx: Context) = EntryPointAnnotType.symbol.asClass
lazy val ImplicitNotFoundAnnotType = ctx.requiredClassRef("scala.annotation.implicitNotFound")
def ImplicitNotFoundAnnot(implicit ctx: Context) = ImplicitNotFoundAnnotType.symbol.asClass
lazy val InlineAnnotType = ctx.requiredClassRef("scala.inline")
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/NameKinds.scala
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ object NameKinds {
val SkolemName = new UniqueNameKind("?")
val LiftedTreeName = new UniqueNameKind("liftedTree")
val SuperArgName = new UniqueNameKind("$superArg$")
val SpecializedName = new UniqueNameKind("$spec")
val DefaultExceptionName = new UniqueNameKind(nme.DEFAULT_EXCEPTION_NAME.toString)

/** A kind of unique extension methods; Unlike other unique names, these can be
* unmangled.
Expand Down
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Phases.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import config.Printers.config
import scala.collection.mutable.{ListBuffer, ArrayBuffer}
import dotty.tools.dotc.transform.TreeTransforms.{TreeTransformer, MiniPhase, TreeTransform}
import dotty.tools.dotc.transform._
import dotty.tools.dotc.transform.linker._
import Periods._
import typer.{FrontEnd, RefChecks}
import ast.tpd
Expand Down Expand Up @@ -243,6 +244,7 @@ object Phases {
private val explicitOuterCache = new PhaseCache(classOf[ExplicitOuter])
private val gettersCache = new PhaseCache(classOf[Getters])
private val genBCodeCache = new PhaseCache(classOf[GenBCode])
private val summariesCache = new PhaseCache(classOf[CollectSummaries])

def typerPhase = typerCache.phase
def picklerPhase = picklerCache.phase
Expand All @@ -257,6 +259,7 @@ object Phases {
def explicitOuterPhase = explicitOuterCache.phase
def gettersPhase = gettersCache.phase
def genBCodePhase = genBCodeCache.phase
def summariesPhase = summariesCache.phase

def isAfterTyper(phase: Phase): Boolean = phase.id > typerPhase.id
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/StdNames.scala
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ object StdNames {
val info: N = "info"
val inlinedEquals: N = "inlinedEquals"
val isArray: N = "isArray"
val isDefined: N = "isDefined"
val isDefinedAt: N = "isDefinedAt"
val isDefinedAtImpl: N = "$isDefinedAt"
val isDefined: N = "isDefined"
val isEmpty: N = "isEmpty"
val isInstanceOf_ : N = "isInstanceOf"
val java: N = "java"
Expand Down
4 changes: 4 additions & 0 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import util.Stats
import java.util.WeakHashMap
import config.Config
import config.Printers.{completions, incremental, noPrinter}
import classfile.ClassfileParser
import dotty.tools.dotc.core.tasty.DottyUnpickler

trait SymDenotations { this: Context =>
import SymDenotations._
Expand Down Expand Up @@ -1236,6 +1238,8 @@ object SymDenotations {
initRunId: RunId)
extends SymDenotation(symbol, ownerIfExists, name, initFlags, initInfo, initPrivateWithin) {

private[dotc] var dottyUnpickler: Option[DottyUnpickler] = None

import util.LRUCache

// ----- caches -------------------------------------------------------
Expand Down
32 changes: 27 additions & 5 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1935,6 +1935,18 @@ object Types {
class TermRefWithFixedSym(prefix: Type, name: TermName, val fixedSym: TermSymbol) extends TermRef(prefix, name) with WithFixedSym
class TypeRefWithFixedSym(prefix: Type, name: TypeName, val fixedSym: TypeSymbol) extends TypeRef(prefix, name) with WithFixedSym

/* used by linker */
final class TypeRefWithFixedSymAndInfo(prefix: Type, name: TypeName, fixedSym: TypeSymbol, val underl: Type) extends TypeRefWithFixedSym(prefix, name, fixedSym) {
override def derivedSelect(prefix: Type)(implicit ctx: Context): Type = {
assert(prefix eq this.prefix, "loss in precision")
this
}

override def info(implicit ctx: Context): Type = underl

override def equals(that: Any): Boolean = that.isInstanceOf[TypeRefWithFixedSymAndInfo] && super.equals(that) && this.underl == that.asInstanceOf[TypeRefWithFixedSymAndInfo].underl
}

/** Assert current phase does not have erasure semantics */
private def assertUnerased()(implicit ctx: Context) =
if (Config.checkUnerased) assert(!ctx.phase.erasedTypes)
Expand Down Expand Up @@ -2045,6 +2057,10 @@ object Types {
*/
def withFixedSym(prefix: Type, name: TypeName, sym: TypeSymbol)(implicit ctx: Context): TypeRef =
unique(new TypeRefWithFixedSym(prefix, name, sym))

def withFixedSymAndInfo(prefix: Type, name: TypeName, sym: TypeSymbol, info: Type)(implicit ctx: Context): TypeRef = {
unique(new TypeRefWithFixedSymAndInfo(prefix, name, sym, info))
}

/** Create a type ref referring to given symbol with given name.
* This is very similar to TypeRef(Type, Symbol),
Expand Down Expand Up @@ -3440,22 +3456,28 @@ object Types {
// ----- Annotated and Import types -----------------------------------------------

/** An annotated type tpe @ annot */
case class AnnotatedType(tpe: Type, annot: Annotation)
extends UncachedProxyType with ValueType {
abstract case class AnnotatedType(tpe: Type, annot: Annotation)
extends CachedProxyType with ValueType {
// todo: cache them? but this makes only sense if annotations and trees are also cached.
override def underlying(implicit ctx: Context): Type = tpe
def derivedAnnotatedType(tpe: Type, annot: Annotation) =
def derivedAnnotatedType(tpe: Type, annot: Annotation)(implicit ctx: Context) =
if ((tpe eq this.tpe) && (annot eq this.annot)) this
else AnnotatedType(tpe, annot)

override def stripTypeVar(implicit ctx: Context): Type =
derivedAnnotatedType(tpe.stripTypeVar, annot)
override def stripAnnots(implicit ctx: Context): Type = tpe.stripAnnots

override def computeHash: Int = doHash(annot, tpe)
}

class CachedAnnotatedType(tpe: Type, annot: Annotation) extends AnnotatedType(tpe, annot)

object AnnotatedType {
def make(underlying: Type, annots: List[Annotation]) =
(underlying /: annots)(AnnotatedType(_, _))
def apply(tpe: Type, annot: Annotation)(implicit ctx: Context) =
unique(new CachedAnnotatedType(tpe, annot))
def make(underlying: Type, annots: List[Annotation])(implicit ctx: Context) =
(underlying /: annots)(apply(_, _))
}

// Special type objects and classes -----------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package classfile
import Contexts._, Symbols._, Types._, Names._, StdNames._, NameOps._, Scopes._, Decorators._
import SymDenotations._, unpickleScala2.Scala2Unpickler._, Constants._, Annotations._, util.Positions._
import NameKinds.{ModuleClassName, DefaultGetterName}
import tasty.DottyUnpickler
import ast.tpd._
import java.io.{ ByteArrayInputStream, DataInputStream, File, IOException }
import java.lang.Integer.toHexString
Expand Down Expand Up @@ -145,6 +146,13 @@ class ClassfileParser(
setClassInfo(moduleRoot, staticInfo)
}

result match {
case result @ Some(_: DottyUnpickler) =>
classRoot.dottyUnpickler = result.asInstanceOf[Option[DottyUnpickler]]
moduleRoot.dottyUnpickler = result.asInstanceOf[Option[DottyUnpickler]]
case _ =>
}

// eager load java enum definitions for exhaustivity check of pattern match
if (isEnum) {
instanceScope.toList.map(_.ensureCompleted())
Expand Down
26 changes: 26 additions & 0 deletions compiler/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import util.{SourceFile, NoSource}
import Annotations.Annotation
import core.Mode
import classfile.ClassfileParser
import dotty.tools.dotc.transform.linker.summaries.MethodSummary
import dotty.tools.dotc.transform.linker.summaries.TastySummaries
import scala.collection.mutable

object DottyUnpickler {

Expand All @@ -27,6 +30,13 @@ object DottyUnpickler {
def unpickle(reader: TastyReader, nameAtRef: NameTable) =
new PositionUnpickler(reader)
}

class SummariesTreeSectionUnpickler(symAtAddr: mutable.HashMap[Addr, Symbol], sectionName: String)
extends TreeSectionUnpickler(posUnpickler = None) {
override def unpickle(reader: TastyReader, tastyName: NameTable): SummariesTreeUnpickler = {
new SummariesTreeUnpickler(symAtAddr, reader, tastyName, sectionName)
}
}
}

/** A class for unpickling Tasty trees and symbols.
Expand Down Expand Up @@ -57,4 +67,20 @@ class DottyUnpickler(bytes: Array[Byte]) extends ClassfileParser.Embedded {
myBody
} else computeBody()
}

def summaries(implicit ctx: Context): List[MethodSummary] = {
val sectionName = TastySummaries.sectionName
val tastySection = unpickler.unpickle(new SummariesTreeSectionUnpickler(treeUnpickler.symAtAddr, sectionName)).get
tastySection.asInstanceOf[SummariesTreeUnpickler].getStartReader(ctx) match {
case Some(treeReader) =>
val unp = new TastyUnpickler.SectionUnpickler[List[MethodSummary]](sectionName) {
def unpickle(reader: TastyReader, tastyName: NameTable): List[MethodSummary] =
new TastySummaries.SummaryReader(treeReader, reader)(ctx).read()
}
unpickler.unpickle(unp).getOrElse(Nil)

case None => Nil
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package dotty.tools.dotc.core.tasty

import dotty.tools.dotc.core.Contexts.Context
import dotty.tools.dotc.core.Symbols._
import dotty.tools.dotc.core.Mode
import dotty.tools.dotc.core.Names.TermName
import dotty.tools.dotc.core.tasty.TastyBuffer.{Addr, NameRef}

import scala.collection.mutable

class SummariesTreeUnpickler(override val symAtAddr: mutable.HashMap[Addr, Symbol], reader: TastyReader, tastyName: NameRef => TermName, sectionName: String)
extends TreeUnpickler(reader, tastyName, posUnpicklerOpt = None) {

roots = Set.empty

def getStartReader(implicit ctx: Context): Option[TreeReader] = {
val st = new TreeReader(reader)
st.skipToplevel()(ctx.addMode(Mode.AllowDependentFunctions))

while (true) {
while (reader.nextByte != TastyFormat.VALDEF && !reader.isAtEnd) st.skipTree()
if (reader.isAtEnd) return None // no section here
val tag = reader.readByte()
val end = reader.readEnd()
val name = st.readName()
if (name.toString == sectionName) return Some(st.forkAt(end))
st.skipTree() // skip type
st.skipTree() // skip rhs
}

None
}

}
5 changes: 5 additions & 0 deletions compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ class TreePickler(pickler: TastyPickler) {
writeByte(if (tpe.isType) TYPEREFdirect else TERMREFdirect)
pickleSymRef(sym)
}
else if (tpe.isTerm) {
writeByte(TERMREF) // should be changed to a new entry that keeps track of prefix, symbol & owner
pickleName(tpe.name)
pickleType(tpe.prefix)
}
else {
assert(tpe.symbol.isClass)
assert(tpe.symbol.is(Flags.Scala2x), tpe.symbol.showLocated)
Expand Down
Loading