Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.dynjs.compiler.jit;
 
 
public class JITBasicBlockCompiler implements BasicBlockCompiler {
    private Executor compilationQueue;
    public JITBasicBlockCompiler(Config configInterpretingVisitorFactory interpFactoryCodeGeneratingVisitorFactory factory) {
        this. = interpFactory;
        this. = new BytecodeBasicBlockCompiler(configfactory);
        this. = Executors.newFixedThreadPool(5, new ThreadFactory() {
            private final AtomicInteger count = new AtomicInteger(1);
            public Thread newThread(Runnable runnable) {
                Thread thread = new Thread(runnable);
                thread.setName("JITBasicBlockCompiler-" + .getAndIncrement());
                thread.setDaemon(true);
                return thread;
            }
        });
    }
    @Override
    public BasicBlock compile(ExecutionContext contextString gristStatement bodyboolean strict) {
        int statementNumber = body.getStatementNumber();
        Entry entry = context.getBlockManager().retrieve(statementNumber);
        BasicBlock code = entry.getCompiled();
        if (code != null) {
            return code;
        }
        InterpretedBasicBlock initial = new InterpretedBasicBlock(this.bodystrict);
        code = new CompilableBasicBlock(thisgristinitial);
        entry.setCompiled(code);
        return code;
    }
    private BasicBlock jitCompile(ExecutionContext contextString gristStatement bodyboolean strict) {
        return this..compile(contextgristbodystrict);
    }
    public void requestJitCompilation(ExecutionContext contextCompilableBasicBlock block) {
        this..execute(new CompileRequest(contextblock));
    }
    private class CompileRequest implements Runnable {
        private ExecutionContext context;
        private CompilableBasicBlock block;
        public CompileRequest(ExecutionContext contextCompilableBasicBlock block) {
            this. = context;
            this. = block;
        }
        @Override
        public void run() {
            BasicBlock delegate = this..getDelegate();
            if (delegate instanceof InterpretedBasicBlock) {
                BasicBlock compiled = jitCompile(this..getGrist(), ((InterpretedBasicBlockdelegate).getBody(), .isStrict());
                this..setDelegate(compiled);
            }
        }
    }
New to GrepCode? Check out our FAQ X