Skip to content
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

Cleanup phase assembly #7622

Closed
scabug opened this issue Jun 27, 2013 · 9 comments
Closed

Cleanup phase assembly #7622

scabug opened this issue Jun 27, 2013 · 9 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jun 27, 2013

Our phase assembly code is not in the greatest shape. For example, if you run scalac -Xshow-phases you get:

             phase name  id  description
             ----------  --  -----------
                 parser   1  parse source into ASTs, perform simple desugaring
                  namer   2  resolve names, attach symbols to named trees
         packageobjects   3  load package objects
                  typer   4  the meat and potatoes: type the trees
                 patmat   5  translate match expressions
         superaccessors   6  add super accessors in traits and nested classes
             extmethods   7  add extension methods for inline classes
                pickler   8  serialize symbol tables
              refchecks   9  reference/override checking, translate nested objects
           selectiveanf  10  
           selectivecps  11  
                uncurry  12  uncurry, translate function values to anonymous classes
              tailcalls  13  replace tail calls by jumps
             specialize  14  @specialized-driven class and method specialization
          explicitouter  15  this refs to outer pointers, translate patterns
                erasure  16  erase types, add interfaces for traits
            posterasure  17  clean up erased inline classes
               lazyvals  18  allocate bitmaps, translate lazy vals into lazified defs
             lambdalift  19  move nested functions to top level
           constructors  20  move field definitions into constructors
                flatten  21  eliminate inner classes
                  mixin  22  mixin composition
                cleanup  23  platform-specific cleanups, generate reflective calls
                  icode  24  generate portable intermediate code
                inliner  25  optimization: do inlining
inlineExceptionHandlers  26  optimization: inline exception handlers
               closelim  27  optimization: eliminate uncalled closures
                    dce  28  optimization: eliminate dead code
                    jvm  29  generate JVM bytecode
               terminal  30  The last phase in the compiler chain

Note that optimizer phases are there even if optimizer is not turned on. What happens is that each phase checks optimize flag and if it's disabled then it skips execution of that phase. What we should do instead is to have a proper phase assembly logic that includes phases that are going to be used in given compiler run.

@scabug
Copy link
Author

scabug commented Jun 27, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7622?orig=1
Reporter: @gkossakowski
Affected Versions: 2.10.1-RC1

@scabug
Copy link
Author

scabug commented Jul 10, 2013

@adriaanm said:
Unassigning and rescheduling to M6 as previous deadline was missed.

@scabug
Copy link
Author

scabug commented Jul 21, 2013

@som-snytt said:
I've coded these features, please let me know if there are more would-be-nice-to-haves:

Plugin can opt out when it processes options; phase can opt out via enabled property; phase can declare that it "requires" other phases to be installed; phase can declare that it wishes to replace or delete another phase (where replace means delete and inherit its ordering constraints).

Also, -Xshow-phases shows the configuration with opt-outs. Using -Xshow-phases -Ydebug will include the phases that opted-out (e.g., no -P:continuations:enabled) with a helper footnote.

I deleted my deletion of Phases since soc has it covered.

@scabug
Copy link
Author

scabug commented Jul 22, 2013

@gkossakowski said:
Hi!

It's not clear to me how plugin improvements are related to this ticket. The ticket talks about very specific issue we have in Global.scala with phase assembly logic that does not respect -optimize flag.

@scabug
Copy link
Author

scabug commented Jul 23, 2013

@som-snytt said (edited on Jul 23, 2013 6:18:24 AM UTC):
The issue you describe also applies to continuations plugin phases in your example, so I think phases need uniform treatment.

I'll start a discussion on the ML for consensus before requesting a review, but I think it's straightforward for a phase (specifically, the SubComponent) to declare if it is enabled (sometimes that is just a setting).

Currently, I have:

apm@mara:~/tmp$ skalac -Xshow-phases 
    phase name  id  description
    ----------  --  -----------
        parser   1  parse source into ASTs, perform simple desugaring
         namer   2  resolve names, attach symbols to named trees
packageobjects   3  load package objects
         typer   4  the meat and potatoes: type the trees
        patmat   5  translate match expressions
superaccessors   6  add super accessors in traits and nested classes
    extmethods   7  add extension methods for inline classes
       pickler   8  serialize symbol tables
     refchecks   9  reference/override checking, translate nested objects
       uncurry  10  uncurry, translate function values to anonymous classes
     tailcalls  11  replace tail calls by jumps
    specialize  12  @specialized-driven class and method specialization
 explicitouter  13  this refs to outer pointers, translate patterns
       erasure  14  erase types, add interfaces for traits
   posterasure  15  clean up erased inline classes
      lazyvals  16  allocate bitmaps, translate lazy vals into lazified defs
    lambdalift  17  move nested functions to top level
  constructors  18  move field definitions into constructors
       flatten  19  eliminate inner classes
         mixin  20  mixin composition
       cleanup  21  platform-specific cleanups, generate reflective calls
         icode  22  generate portable intermediate code
           jvm  23  generate JVM bytecode
      terminal  24  the last phase during a compilation run

apm@mara:~/tmp$ skalac -Xshow-phases -Yinline
    phase name  id  description
    ----------  --  -----------
        parser   1  parse source into ASTs, perform simple desugaring
         namer   2  resolve names, attach symbols to named trees
packageobjects   3  load package objects
         typer   4  the meat and potatoes: type the trees
        patmat   5  translate match expressions
superaccessors   6  add super accessors in traits and nested classes
    extmethods   7  add extension methods for inline classes
       pickler   8  serialize symbol tables
     refchecks   9  reference/override checking, translate nested objects
       uncurry  10  uncurry, translate function values to anonymous classes
     tailcalls  11  replace tail calls by jumps
    specialize  12  @specialized-driven class and method specialization
 explicitouter  13  this refs to outer pointers, translate patterns
       erasure  14  erase types, add interfaces for traits
   posterasure  15  clean up erased inline classes
      lazyvals  16  allocate bitmaps, translate lazy vals into lazified defs
    lambdalift  17  move nested functions to top level
  constructors  18  move field definitions into constructors
       flatten  19  eliminate inner classes
         mixin  20  mixin composition
       cleanup  21  platform-specific cleanups, generate reflective calls
         icode  22  generate portable intermediate code
       inliner  23  optimization: do inlining
           jvm  24  generate JVM bytecode
      terminal  25  the last phase during a compilation run

apm@mara:~/tmp$ skalac -Xshow-phases -P:continuations:enable -optimise
    phase name  id  description
    ----------  --  -----------
        parser   1  parse source into ASTs, perform simple desugaring
         namer   2  resolve names, attach symbols to named trees
packageobjects   3  load package objects
         typer   4  the meat and potatoes: type the trees
        patmat   5  translate match expressions
superaccessors   6  add super accessors in traits and nested classes
    extmethods   7  add extension methods for inline classes
       pickler   8  serialize symbol tables
     refchecks   9  reference/override checking, translate nested objects
  selectiveanf  10  ANF pre-transform for @cps
  selectivecps  11  @cps-driven transform of selectiveanf assignments
       uncurry  12  uncurry, translate function values to anonymous classes
     tailcalls  13  replace tail calls by jumps
    specialize  14  @specialized-driven class and method specialization
 explicitouter  15  this refs to outer pointers, translate patterns
       erasure  16  erase types, add interfaces for traits
   posterasure  17  clean up erased inline classes
      lazyvals  18  allocate bitmaps, translate lazy vals into lazified defs
    lambdalift  19  move nested functions to top level
  constructors  20  move field definitions into constructors
       flatten  21  eliminate inner classes
         mixin  22  mixin composition
       cleanup  23  platform-specific cleanups, generate reflective calls
         icode  24  generate portable intermediate code
       inliner  25  optimization: do inlining
inlinehandlers  26  optimization: inline exception handlers
      closelim  27  optimization: eliminate uncalled closures
      constopt  28  optimization: optimize null and other constants
           dce  29  optimization: eliminate dead code
           jvm  30  generate JVM bytecode
      terminal  31  the last phase during a compilation run

Under -Ydebug, you see all available components, with symbols for xx disabled and oo skipped.

apm@mara:~/tmp$ skalac -Xshow-phases -Yskip:jvm -Ydebug
    phase name  id  description
    ----------  --  -----------
        parser   1  parse source into ASTs, perform simple desugaring
         namer   2  resolve names, attach symbols to named trees
packageobjects   3  load package objects
         typer   4  the meat and potatoes: type the trees
        patmat   5  translate match expressions
superaccessors   6  add super accessors in traits and nested classes
    extmethods   7  add extension methods for inline classes
       pickler   8  serialize symbol tables
     refchecks   9  reference/override checking, translate nested objects
  selectiveanf  xx  ANF pre-transform for @cps
  selectivecps  xx  @cps-driven transform of selectiveanf assignments
       uncurry  10  uncurry, translate function values to anonymous classes
     tailcalls  11  replace tail calls by jumps
    specialize  12  @specialized-driven class and method specialization
 explicitouter  13  this refs to outer pointers, translate patterns
       erasure  14  erase types, add interfaces for traits
   posterasure  15  clean up erased inline classes
      lazyvals  16  allocate bitmaps, translate lazy vals into lazified defs
    lambdalift  17  move nested functions to top level
  constructors  18  move field definitions into constructors
       flatten  19  eliminate inner classes
         mixin  20  mixin composition
       cleanup  21  platform-specific cleanups, generate reflective calls
         icode  22  generate portable intermediate code
       inliner  xx  optimization: do inlining
inlinehandlers  xx  optimization: inline exception handlers
      closelim  xx  optimization: eliminate uncalled closures
      constopt  xx  optimization: optimize null and other constants
           dce  xx  optimization: eliminate dead code
           jvm  oo  generate JVM bytecode
      terminal  23  the last phase during a compilation run

@scabug
Copy link
Author

scabug commented Jul 24, 2013

@gkossakowski said (edited on Jul 24, 2013 5:29:22 PM UTC):
While I'm all for uniform treatment I think we need to take baby steps here. I learnt from experience that we are in territory where changing anything is hard.

It seems like scala/scala#2768 confirms my worries.

@scabug
Copy link
Author

scabug commented Jul 24, 2013

@som-snytt said:
The PR is the baby step. Just have to make sure the baby isn't missing any toes.

@scabug
Copy link
Author

scabug commented Aug 8, 2013

@som-snytt said:
Unassigning to foster whatever the opposite of work stealing is.

@scabug scabug closed this as completed Sep 12, 2013
@scabug
Copy link
Author

scabug commented Sep 12, 2013

@gkossakowski said:
Fixed by scala/scala#2859

@scabug scabug added this to the 2.11.0-M6 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants