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

Crash in dead code elimination: could not find init #8334

Closed
scabug opened this issue Feb 24, 2014 · 4 comments
Closed

Crash in dead code elimination: could not find init #8334

scabug opened this issue Feb 24, 2014 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Feb 24, 2014

Rex ran into it while working on optimizing List operations. Minimized version looks like this:

package abc

class Bar(head: AnyRef)

class A {
  @inline
  final def mapp(f: AnyRef => AnyRef): AnyRef = {
    new Bar(f(null))
  }
  def f: Boolean = {
    mapp (_ => return false)
    true
  }
}

when compiled with -optimize we get:

error: could not find init in: abc.A.f
error: scala.reflect.internal.FatalError:
  could not find init in: abc.A.f
     while compiling: OptimizerCrash.scala
        during phase: dce
[..]

== Source file context for tree position ==

    11   }
    12   def f: Boolean = {
    13     mapp (_ => return false)
    14     true
    15   }
    16 }
	at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:57)
	at scala.tools.nsc.Global.abort(Global.scala:268)
	at scala.tools.nsc.backend.opt.DeadCodeElimination$DeadCode.scala$tools$nsc$backend$opt$DeadCodeElimination$DeadCode$$findInstruction(DeadCodeElimination.scala:432)
	at scala.tools.nsc.backend.opt.DeadCodeElimination$DeadCode.mark(DeadCodeElimination.scala:261)
	at scala.tools.nsc.backend.opt.DeadCodeElimination$DeadCode.dieCodeDie(DeadCodeElimination.scala:103)
	at scala.tools.nsc.backend.opt.DeadCodeElimination$DeadCode$$anonfun$analyzeClass$2.apply(DeadCodeElimination.scala:60)
	at scala.tools.nsc.backend.opt.DeadCodeElimination$DeadCode$$anonfun$analyzeClass$2.apply(DeadCodeElimination.scala:58)
@scabug
Copy link
Author

scabug commented Feb 24, 2014

@scabug
Copy link
Author

scabug commented Feb 24, 2014

@gkossakowski said (edited on Feb 25, 2014 12:27:07 AM UTC):
Things go south in inliner, if you check icode after inliner phase (with -Xprint-icode) you'll see:

class A extends Object {
  // fields:
  
  // methods
  def mapp(f: Function1 (REF(trait Function1))): Object {
  locals: value f
  startBlock: 1
  blocks: [1]
  
  1: 
    8	NEW REF(class Bar)
    8	DUP(REF(class Bar))
    8	LOAD_LOCAL(value f)
    8	CONSTANT(null)
    8	CALL_METHOD scala.Function1.apply (dynamic)
    8	CALL_METHOD abc.Bar.<init> (static-instance)
    8	RETURN(REF(class Object))

def f(): Boolean {

[...]
    
  9: 
    11	NEW REF(class Bar)
    11	DUP(REF(class Bar))
    11	LOAD_LOCAL(variable f1)
    11	CONSTANT(null)
// whoops, where are my two method calls that should be copied from block 1 seen above?
    11	STORE_LOCAL(variable v11)
    11	STORE_LOCAL(variable $inlThis2)
    11	JUMP 11

@scabug
Copy link
Author

scabug commented Aug 28, 2015

@lrytz said:
scala/scala#3498

@scabug
Copy link
Author

scabug commented Aug 28, 2015

@lrytz said:
fixed in new optimizer, test in scala/scala#4711

@scabug scabug closed this as completed Jan 27, 2016
@scabug scabug added the critical label Apr 7, 2017
@scabug scabug added this to the 2.12.0-M4 milestone Apr 7, 2017
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

No branches or pull requests

2 participants