Aladdin - Scala Bugtracking
[#243] project: compiler priority: low category: bug
submitter assigned to status date submitted
Burak _ fixed 2003-12-01 12:40:40.0
subject medium-length patterns crash backend
code
object bugFJ_1 {
  def extract( cs:char* ):Unit = cs match {
    case Seq(_*,'\\',src @ _ *,'\\','e','n','d','{','l','s','t','l','i','s','t',rest @ _ *  )
      =>
  }
}
what happened
Exception in thread "main" java.lang.AssertionError: 71212
	at ch.epfl.lamp.util.ByteArray.putU2(ByteArray.java:93)
	at ch.epfl.lamp.fjbg.JCode.patchAllOffset(JCode.java:907)
	at ch.epfl.lamp.fjbg.JCode.freeze(JCode.java:95)
	at ch.epfl.lamp.fjbg.JMethod.freeze(JMethod.java:81)
	at ch.epfl.lamp.fjbg.JFieldOrMethod.writeTo(JFieldOrMethod.java:129)
	at ch.epfl.lamp.fjbg.JClass.writeTo(JClass.java:320)
	at ch.epfl.lamp.fjbg.JClass.writeTo(JClass.java:272)
	at ch.epfl.lamp.fjbg.JClass.writeTo(JClass.java:256)
	at scalac.backend.jvm.GenJVM.leaveClass(GenJVM.java:1563)
	at scalac.backend.jvm.GenJVM.gen(GenJVM.java:139)
	at scalac.backend.jvm.GenJVM.translate(GenJVM.java:110)
	at scalac.backend.jvm.GenJVMPhase.apply(GenJVMPhase.java:45)
	at scalac.Global.compile(Global.java:300)
	at scalac.Global.compile(Global.java:272)
	at scala.tools.scalac.Main$.main(sources/scala/tools/scalac/Main.scala:33)
	at scala.tools.scalac.Main.main(sources/scala/tools/scalac/Main.scala)
what expected silent run
[back to overview]
Changes of this bug report
Burak  edited on  2003-12-01 12:41:27.0
Similar to the bug 242, but different error.
Michel  edited on  2003-12-02 09:37:05.0

The problem here is that the pattern matcher generates code which is far too big for the JVM. The JVM has several limits, for example on the size of the code that a method can contain (65k IIRC), the size of jump labels, and so on.

It is not clear to me whether we should fix that directly in the back-end or earlier. Therefore I re-assigned the bug to nobody.

Michel  edited on  2003-12-02 13:16:02.0

In fact, this was a duplicate of 242, and it is therefore fixed now. The problem of the limits of the JVM remain, though, but since the Java compilers I tried (namely javac and pico) do nothing special when these limits are reached, I guess we can ignore the problem in the short term.

I still think the pattern matcher should be changed to avoid the creation of such large code for simple code like this, but as I said Buraq is aware of this.

Burak  edited on  2003-12-02 16:50:10.0
The inefficient if..then..else chains are removed, now switches are created instead.