Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
public class Simple {
  public static int tailcaller(int x) {
    if (x==0) return x+1;

    return goto tailcaller(x-1);
  }
}

Generating code

There are two bytecode verifiers in the jdk. The old type-inference verifier and the new type-checking verifier. The type-checking verifier is used if the class file format major version is >= 50. To use this verifier, a valid stackmaptable attribute has to be emitted. Tail calls are currently only supported when the new verifier is used. Hence, to use tail calls the generated class file must have a version number >= 50.0 and must contain a valid stackmaptable attribute.

The default behaviour of the jvm is to fall back to the old verifier if the new verifier fails (e.g because the stackmaptable attribute is invalid). This can lead to confusing messages that the bytecode at index of wide is invalid. The jvm has an option to disable this behaviour.

Code Block

java -XX:-FailOverToOldVerifier -XX:+TailCalls Generatelass

Implementation

e
... more to come.

In the meantime some implementation details can be found in:
http://www.ssw.uni-linz.ac.at/Research/Papers/Schwaighofer09Master/

...