Skip to content

Need a new phase, that will lift try bodies #742

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

Closed
DarkDimius opened this issue Jul 28, 2015 · 1 comment · Fixed by #748
Closed

Need a new phase, that will lift try bodies #742

DarkDimius opened this issue Jul 28, 2015 · 1 comment · Fixed by #748
Assignees

Comments

@DarkDimius
Copy link
Contributor

This is the current blocker for the bootstrap. I'm working on it

Exception in thread "main" java.lang.VerifyError: Inconsistent stackmap frames at branch target 54
Exception Details:
  Location:
    Test$.implicits()V @51: goto
  Reason:
    Current frame's stack size doesn't match stackmap.
  Current Frame:
    bci: @51
    flags: { }
    locals: { 'Test$', 'java/lang/Throwable', 'java/lang/Throwable', 'java/lang/Exception' }
    stack: { null }
  Stackmap Frame:
    bci: @54
    flags: { }
    locals: { 'Test$' }
    stack: { 'Test$', 'scala/runtime/Null$' }
  Bytecode:
    0x0000000: 2a2a b600 24a7 0031 4c2b 4da7 0025 2cc1
    0x0000010: 0026 9a00 06a7 000c 2cc0 0026 4e01 a700
    0x0000020: 0fa7 0009 2bbf 0000 00bf a7ff faa7 0006
    0x0000030: a7ff dea7 0003 b600 28b1
  Exception Handler Table:
    bci [1, 5] => handler: 8
  Stackmap Table:
    same_locals_1_stack_item_frame(@8,Object[#34])
    append_frame(@14,Object[#34],Object[#34])
    same_frame(@24)
    same_frame(@33)
    same_frame(@36)
    full_frame(@38,{},{Object[#34]})
    append_frame(@42,Object[#2],Object[#34],Object[#34])
    full_frame(@45,{Object[#2],Object[#34],Object[#34],Object[#38]},{Null})
    chop_frame(@48,1)
    full_frame(@51,{Object[#2],Object[#34],Object[#34],Object[#38]},{Null})
    full_frame(@54,{Object[#2]},{Object[#2],Object[#44]})

    at Test.main(StackMap.scala)

minimized source:

object Test {
  var implicitsCache = null

  def main(args: Array[String]): Unit = {
    implicits
  }

  def implicits = {
     implicitsCache = {
       try{ this.implicitsCache} catch { case ex: Exception => null }
     }
  }
}

happens for this classfile: https://yadi.sk/d/EZulESoWi8g4a

@DarkDimius DarkDimius self-assigned this Jul 28, 2015
@DarkDimius
Copy link
Contributor Author

Ok, it happens as exception handler runs with stack that has a single value - exception, meaning that
this that was pushed before is already popped.

In scalac It is handled by uncurry: https://github.com/scala/scala/blob/62e915decc3e4caf01a9d19392c6adbdf6b55154/src/compiler/scala/tools/nsc/transform/UnCurry.scala#L510

We need to implement a phase that does the same.

DarkDimius added a commit to dotty-staging/dotty that referenced this issue Jul 28, 2015
Making a correct fix could take some time,
and I want to find other issues before I start working on this one.
@DarkDimius DarkDimius changed the title Inconsistent stackmap Need a new phase, that will lift try bodies Jul 28, 2015
odersky added a commit to dotty-staging/dotty that referenced this issue Aug 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants