jaroslav@1812: /** jaroslav@1812: * Back 2 Browser Bytecode Translator jaroslav@1812: * Copyright (C) 2012-2015 Jaroslav Tulach jaroslav@1812: * jaroslav@1812: * This program is free software: you can redistribute it and/or modify jaroslav@1812: * it under the terms of the GNU General Public License as published by jaroslav@1812: * the Free Software Foundation, version 2 of the License. jaroslav@1812: * jaroslav@1812: * This program is distributed in the hope that it will be useful, jaroslav@1812: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@1812: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@1812: * GNU General Public License for more details. jaroslav@1812: * jaroslav@1812: * You should have received a copy of the GNU General Public License jaroslav@1812: * along with this program. Look for COPYING file in the top folder. jaroslav@1812: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@1812: */ jaroslav@1812: package org.apidesign.bck2brwsr.flow; jaroslav@1812: jaroslav@1842: import java.io.IOException; jaroslav@1812: import org.apidesign.vm4brwsr.Bck2Brwsr; jaroslav@1812: jaroslav@1812: /** Poweful flow analyzer. Based on internals used by Graal JVM jaroslav@1812: * compiler. jaroslav@1812: * jaroslav@1812: * @author Jaroslav Tulach jaroslav@1812: */ jaroslav@1812: public final class GraalFlowAnalyzer { jaroslav@1812: private GraalFlowAnalyzer() { jaroslav@1812: } jaroslav@1812: jaroslav@1812: public static Bck2Brwsr.Flow.Analyzer getDefault() { jaroslav@1812: return Impl.DEFAULT; jaroslav@1812: } jaroslav@1812: jaroslav@1812: private static class Impl implements Bck2Brwsr.Flow.Analyzer { jaroslav@1812: static Impl DEFAULT = new Impl(); jaroslav@1812: jaroslav@1812: private Impl() { jaroslav@1812: } jaroslav@1812: jaroslav@1812: @Override jaroslav@1842: public boolean analyze(final Bck2Brwsr.Flow result) throws IOException { jaroslav@1842: // Use Graal to generate optimal function, David. jaroslav@1841: double x = com.oracle.graal.api.directives.GraalDirectives.FASTPATH_PROBABILITY; jaroslav@1842: result.emit("function() { return 922869; }"); jaroslav@1842: return true; jaroslav@1812: } jaroslav@1812: } jaroslav@1812: }