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

-Xcheckinit generating bad bitmaps #4072

Closed
scabug opened this issue Dec 11, 2010 · 4 comments
Closed

-Xcheckinit generating bad bitmaps #4072

scabug opened this issue Dec 11, 2010 · 4 comments
Assignees

Comments

@scabug
Copy link

scabug commented Dec 11, 2010

The following trunk test case fails when run with -Xcheckinit with a message implying there is something wrong with bitmap generation.

% scalac29 -Xcheckinit -d /tmp files/run/t3895b.scala
% scala29 -cp /tmp Test
java.lang.NoSuchFieldError: bitmap$$7
	at DryRun$$compiler$$.test1(t3895b.scala:10)
	at DryRun.test(t3895b.scala:16)
	at Test$$.main(t3895b.scala:26)

Here is the (unminimized) code.

class DryRun {
  import scala.tools.nsc.{Global, Settings, CompilerCommand}
  import scala.tools.nsc.reporters.ConsoleReporter

  val settings = new Settings()
  settings.classpath.value = System.getProperty("java.class.path")
  val command = new CompilerCommand(List(), settings)
  val reporter = new ConsoleReporter(settings, scala.Console.in, new java.io.PrintWriter(new java.io.PrintStream(scala.Console.out)))
  object compiler extends Global(command.settings, reporter) {
   object test1
   lazy val test2 = 1
   object test3
  }

  def test {
    compiler.test1
    compiler.test2
    compiler.test3
    val run = new compiler.Run
    run compile command.files
  }
}

object Test {
    def main(args: Array[String]) {
        new DryRun().test
    }
}
@scabug
Copy link
Author

scabug commented Dec 11, 2010

Imported From: https://issues.scala-lang.org/browse/SI-4072?orig=1
Reporter: @paulp

@scabug
Copy link
Author

scabug commented Dec 13, 2010

@paulp said:
The issue here appears to be that there is a totally different bitmap layout if things are compiled with or without -Xcheckinit, and when code is compiled with -Xcheckinit it acts like everything else was as well. Here is a diff of Global.scala compiled with and without -Xcheckinit, filtered to the lines mentioning bitmaps.

< const SI-127 = Asciz	bitmap$$4;
< const SI-128 = Asciz	bitmap$$5;
< const SI-141 = NameAndType	SI-128:SI-22;//  bitmap$$5:I
< const SI-142 = Field	SI-140.SI-141;	//  scala/tools/nsc/Global.bitmap$$5:I
< const SI-192 = Asciz	bitmap$$3;
< const SI-193 = NameAndType	SI-192:SI-22;//  bitmap$$3:I
< const SI-194 = Field	SI-191.SI-193;	//  scala/tools/nsc/symtab/SymbolTable.bitmap$$3:I
> const SI-127 = Asciz	bitmap$$6;
> const SI-128 = Asciz	bitmap$$priv$$0;
> const SI-129 = Asciz	bitmap$$7;
> const SI-142 = NameAndType	SI-129:SI-22;//  bitmap$$7:I
> const SI-143 = Field	SI-141.SI-142;	//  scala/tools/nsc/Global.bitmap$$7:I
> const SI-193 = NameAndType	SI-127:SI-22;//  bitmap$$6:I
> const SI-194 = Field	SI-141.SI-193;	//  scala/tools/nsc/Global.bitmap$$6:I
< const SI-606 = NameAndType	SI-127:SI-22;//  bitmap$$4:I
< const SI-607 = Field	SI-140.SI-606;	//  scala/tools/nsc/Global.bitmap$$4:I
< const SI-888 = Asciz	allocate bitmaps, translate lazy vals into lazified defs;
< const SI-889 = String	SI-888;	//  allocate bitmaps, translate lazy vals into lazified defs

Notice bitmap$$6 and bitmap$$7 only appear when compiled with -Xcheckinit.

So I think this brings us back around to the question of why Xcheckinit is sharing bitmaps with the lazy bits.

Here is a more minimized version.

import scala.tools.nsc._

object Test {
  class DryRun {
    val compiler = new Global(new Settings()) { 
      lazy val test1 = new AnyRef
    }
  }
  
  def main(args: Array[String]) {
    new DryRun().compiler.test1
  }
}

@scabug
Copy link
Author

scabug commented Jan 7, 2011

@hubertp said:
(In r23919) Closes #4072. Fields in checkinit mode have their own bitmaps (one for public,private and protected and the other for transient fields). Those bitmaps are never inherited, this way you can freely mix code compiled with/without checkinit flag. Review by dragos

@scabug
Copy link
Author

scabug commented Jan 7, 2011

@paulp said:
Thank you!

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