Giter Club home page Giter Club logo

lazy-allocation-in-java-compiler's Introduction

Lazy Allocation in Java Compiler

Lazy allocation implemented in the sun Java compiler. This project is actually one part of my term thesis that is about optimizing objects allocation in compilers.

Lazy Allocation

There are many ways to delay the allocation of objects, during run-time or static compiling time. This implementation will delay the allocation at compiling time.

Here is an example to illustrate what lazy allocation does in the compiler:

public class Sample{
    public static void main(String[] args){
        int i = 3;
        int j = new Integer(5);
        if ( i < 5 ) {
        } else {
            j = j + 1;
        }
}

After compiling this program, the binary code should be the same with the binary code built from the following code, in which the allocation of an Integer object is moved to the else-part of the if statement. Since the program will not necessarily reach the else-part, this allocation of object will not necessarily happen, which means a potential delay of allocation.

public class Sample{
    public static void main(String[] args){
        int i = 3;
        int j; 
        if ( i < 5 ) {
        } else {
            j = new Integer(5);
            j = j + 1;
        }
}

Compilers

There are only a few files changed in this Java compiler compared with the compiler in OpenJDK repository(langtools-ce654f4ecfd8). I add the following files in the src/share/classes/com/sun/tools/javac/comp directory

  • Delay.java Main pass to delay the object allocation
  • TreeUtil.java Some neat functions
  • Path.java classes for recording a path of certain statements in the syntax tree
  • some other files slightly modified.

lazy-allocation-in-java-compiler's People

Contributors

lijunsong avatar

Watchers

 avatar  avatar

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.