Giter Club home page Giter Club logo

jvm-tail-recursion's People

Contributors

sipkab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

zeta1999

jvm-tail-recursion's Issues

Benchmark

Are there any benchmarks showing the effect of applying the tail-recursion optimizations?

Optimize recursive calls when unoptimizable branches are present in the return path

There may be cases when a tail recursive call has multiple execution paths after the call itself. The optimization should be performed in cases where it is possible.

One example is such:

public static int count(int n) {
	if (n == 0) {
		return 0;
	}
	int v = count(n - 1);
	if (n == 0) {
		callSomeOtherMethod();
	}
	return v;
}

Should be optimized to:

public static int count(int n) {
start:
	if (n == 0) {
		return 0;
	}
	
	if (n == 0) {
		int v = count(n - 1);
		callSomeOtherMethod();
		return v;
	}
	n = n - 1;
	goto start;
}

Current state

Currently we allow branches to be present in the return path, but they all need to be side-effect free. This issue requires individual modifications and analysis to the subsequent execution paths.

ASM error: Class versions V1_5 or less must use F_NEW frames.

I'm getting this error:

Exception in thread "main" java.lang.IllegalArgumentException: Class versions V1_5 or less must use F_NEW frames.
        at sipka.jvm.tailrec.thirdparty.org.objectweb.asm.MethodWriter.visitFrame(MethodWriter.java:779)
        at sipka.jvm.tailrec.thirdparty.org.objectweb.asm.tree.FrameNode.accept(FrameNode.java:141)
        at sipka.jvm.tailrec.thirdparty.org.objectweb.asm.tree.InsnList.accept(InsnList.java:145)
        at sipka.jvm.tailrec.thirdparty.org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:752)
        at sipka.jvm.tailrec.thirdparty.org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:650)
        at sipka.jvm.tailrec.thirdparty.org.objectweb.asm.tree.ClassNode.accept(ClassNode.java:466)
        at sipka.jvm.tailrec.TailRecursionOptimizer.optimizeMethods(TailRecursionOptimizer.java:114)
        at sipka.jvm.tailrec.TailRecursionOptimizer.optimizeMethods(TailRecursionOptimizer.java:92)
        at sipka.jvm.tailrec.MainCommand.optimizeJar(MainCommand.java:208)
        at sipka.jvm.tailrec.MainCommand.optimizeFile(MainCommand.java:182)
        at sipka.jvm.tailrec.MainCommand.call(MainCommand.java:139)
        at sipka.jvm.tailrec.Main.lambda$parse$1(Main.java:166)
        at sipka.jvm.tailrec.Main.callCommand(Main.java:195)
        at sipka.jvm.tailrec.Main.main(Main.java:177)

Version: v0.8.1
Java version used to run: Java 15

The target JAR uses Java 8 as far as I know, but it has some libraries that should be backwards compatible or such for my understanding, otherwise who would on the earth still uses Java 5? There is Java 15!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.