All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jruby.ir.passes.DeadCodeElimination Maven / Gradle / Ivy

There is a newer version: 9.4.9.0
Show newest version
package org.jruby.ir.passes;

import java.util.ArrayList;
import java.util.List;
import org.jruby.ir.IRClosure;
import org.jruby.ir.IRScope;
import org.jruby.ir.dataflow.analyses.LiveVariablesProblem;
import org.jruby.ir.passes.CompilerPass;
import org.jruby.ir.passes.LiveVariableAnalysis;

public class DeadCodeElimination extends CompilerPass {
    public static List> DEPENDENCIES = new ArrayList>() {{
       add(LiveVariableAnalysis.class);
    }};
    
    public String getLabel() {
        return "Dead Code Elimination";
    }

    @Override
    public List> getDependencies() {
        return DEPENDENCIES;
    }
    
    @Override
    public Object execute(IRScope scope, Object... data) {
        ((LiveVariablesProblem) data[0]).markDeadInstructions();

        for (IRClosure cl: scope.getClosures()) {
            run(cl, true);
        }
        
        return true;
    }
    
    public void invalidate(IRScope scope) {
        // FIXME: Can we reset this?
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy