Uploaded image for project: 'JikesRVM'
  1. JikesRVM
  2. RVM-957

Optimizing compiler (at O1+) produces incorrect code for scalac benchmark due to bug in SImpleEscape

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 3.1.2
    • Fix Version/s: 3.1.4
    • Component/s: Compiler: Optimizing
    • Labels:
      None
    • Environment:

      host.name=ia32-linux
      config.name=production

      Description

      The optimizing compiler (at levels O1 or higher) seems to produce incorrect code for a method from the scalac benchmarks of the Scala benchmark suite found at http://repo.scalabench.org/snapshots/org/scalabench/benchmarks/scala-benchmark-suite/0.1.0-SNAPSHOT/scala-benchmark-suite-0.1.0-20120216.103539-3.jar.
      When run with ./dist/production_ia32-linux/rvm -X:aos:enable_recompilation=false -X:aos:initial_compiler=opt -X:irc:O1 -jar scala-benchmark-suite-0.1.0-20120216.103539-3.jar scalac --preserve the following exception ensues:

      Caused by: java.lang.ClassCastException
      at scala.tools.nsc.typechecker.Infer$class.isFullyDefined(Infer.scala:107)
      at scala.tools.nsc.Global$analyzer$.isFullyDefined(Global.scala:301)
      at scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$methTypeArgs$1.apply(Infer.scala:629)
      at scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$methTypeArgs$1.apply(Infer.scala:628)
      at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
      at scala.collection.immutable.List.foreach(List.scala:45)
      at scala.tools.nsc.typechecker.Infer$Inferencer.methTypeArgs(Infer.scala:628)
      at scala.tools.nsc.typechecker.Infer$Inferencer.inferMethodInstance(Infer.scala:1155)
      at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:2501)
      at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:3380)
      at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4049)
      at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4203)
      at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4265)
      at scala.tools.nsc.typechecker.Typers$Typer.typedFunction(Typers.scala:2072)
      at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3921)
      at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4203)
      ...

      When limiting oneself to -X:aos:initial_compiler=opt -X:irc:O1 or -X:aos:initial_compiler=base, this exception does not show up.

      By instrumenting RuntimeEntrypoints.deliverHardwareException I was able to determine the problematic checkcast instruction; it's located at bytecode index 324 in scala.tools.nsc.typechecker.Infer$class.isFullyDefined(scala.tools.nsc.typechecker.Analyzer, scala.tools.nsc.symtab.Types$Type):

      > javap -c -l -classpath scratch/jar/scala-compiler-2.8.1.jar scala.tools.nsc.typechecker.Infer\$class
      public static boolean isFullyDefined(scala.tools.nsc.typechecker.Analyzer, scala.tools.nsc.symtab.Types$Type);
      Code:
      ...
      319: aload 8
      321: invokevirtual #335; //Method scala/Tuple2._1)Ljava/lang/Object;
      324: checkcast #104; //class scala/tools/nsc/symtab/Types$Type
      ...
      LineNumberTable:
      line 296: 304
      line 107: 308
      line 119: 341
      ...

      In BC2IR this checkcast, unlike some others in isFullyDefined is not skipped.

      As this bug is "local" to the isFullyDefined method, it is possible to use a very short compiler advice file (attached) requesting just this method to be compiled to reproduce the bug: ./dist/production_ia32-linux/rvm -X:aos:initial_compiler=base -X:aos:enable_precompile=true -X:aos:enable_recompilation=false -X:aos:cafi=scalac.ca -jar scala-benchmark-suite-0.1.0-20120216.103539-3.jar scalac --preserve

        Attachments

        1. RVM-957.diff
          3 kB
        2. rvm957testcase.tbz
          0.7 kB
        3. RVM-957-UseResultCarrier.diff
          3 kB
        4. scalac.ca
          0.1 kB

          Activity

            People

            • Assignee:
              dgrove dgrove
              Reporter:
              sewe Andreas Sewe
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: