Skip to content

Towards Inlining Untyped Code #4589

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 21 commits into from

Conversation

odersky
Copy link
Contributor

@odersky odersky commented May 26, 2018

We would like inline code that is only typed at the leaves. This seems to be the best way to have an inlining scheme that can generate new types. This ability to generate new types gives us some of the power of whitebox macros. It is needed for most typelevel programming idioms.

This PR is preparatory. It contains

  • Regularization of modifier structure: Mods no longer add any new information, are kept
    only as carriers of positions for syntactic analysis in IDE and elsewhere.
  • Improvements in debug and printing options.
  • Constant folding unary expressions which was forgotten in typer so far.
  • General infrastructure to have untyped splices in typed trees.
  • Code for pickling and unpickling such untyped splices.
  • Drop inline as a modifier for function parameters, use by-name instead.
  • Fixes to inliner to make the previous change work, and in general to do a better job
    reducing the amount of code that's generated.

The PR can be reviewed separately. It will be followed up with another PR, introducing transparent methods, which allow to inline untyped trees.

@odersky odersky force-pushed the change-inline-untpd-2 branch 5 times, most recently from a791e52 to 9a69dbc Compare June 3, 2018 10:59
odersky added 21 commits June 3, 2018 14:55
Introduce UntypedSplice and make TreeCopiers and TreeMaps more regular
to take splices into account.
 - extend scheme to accumulators
 - no need anymore to define special tpd versions of maps and accumulators
 - no extra `typeMap` field needed in typeMap; instead the UntypedSplice
   case is handled directly.
Some refactorings so that it will become easier to generate untyped trees
Use combination of Enum and Case instead.
It's useful to know something was an enum when it started, and it's necessary to pickle
this when serializing untyped trees.
 - Mark splices in code under -print-debug
 - Print owners of all definitions under -print-debug-owners
Allow UNTYPEDSPLICE roots with TYPEDSPLICE subtrees. Trees between them are untyped.
 - need to maintain Type mode bit for correct desugaring
 - need to pickle PatDefs directly since desugaring requires
   too much context.
Everything should be reflected in flags and privateWithin already.
This was previously forgotten, even though unary operations such as `!` and `~` were folded later
in FirstTransform. As a consequence, inlining simplifications involving constant expressions
using these operations were not done. This affected in particular the trace macro, which was always
expanded to an operation taking a closure argument.
Avoid creation of `op1` methods if tracing is not enabled.
Rely on call-by-name parameters instead. Fix "unused defs" logic so
that referred-to cbn parameters are not eliminated.
Since all Mod values are now reflected in flags and privateWithin, there is
no need anymore to test whether a Mod exists.
@odersky odersky force-pushed the change-inline-untpd-2 branch from 1375bf4 to e8c96cb Compare June 3, 2018 12:55
@odersky odersky changed the title Inline Untyped Code Towards Inlining Untyped Code Jun 3, 2018
@odersky
Copy link
Contributor Author

odersky commented Jun 3, 2018

test performance please

@dottybot
Copy link
Member

dottybot commented Jun 3, 2018

performance test scheduled: 1 job(s) in queue, 1 running.

@odersky odersky requested review from biboudis and nicolasstucki June 3, 2018 13:37
@odersky
Copy link
Contributor Author

odersky commented Jun 3, 2018

I admit it would be better to split this into separate PRs. But my time-budget is already overdrawn as is, so I have chosen to push ahead and try to get the subsequent steps done instead.

@dottybot
Copy link
Member

dottybot commented Jun 3, 2018

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/4589/ to see the changes.

Benchmarks is based on merging with master (228b232)

@odersky
Copy link
Contributor Author

odersky commented Jun 5, 2018

Replaced by #4620 for now. Putting decision to pickle untyped trees on hold.

@odersky odersky closed this Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants