Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  *
  */
 package org.jruby.ext.ffi.jffi;
 
final class JITHandle {
    private static final int THRESHOLD = ..load();
    private final JITSignature jitSignature;
    private volatile boolean compilationFailed = false;
    private final AtomicInteger counter = new AtomicInteger(0);
    private final JITCompiler compiler;
    private Reference<Class<? extends NativeInvoker>> compiledClassRef = null;
    JITHandle(JITCompiler compilerJITSignature signatureboolean compilationFailed) {
        this. = compiler;
        this. = signature;
        this. = compilationFailed;
    }
    final boolean compilationFailed() {
        return ;
    }
    final NativeInvoker compile(RubyModule implementationClasscom.kenai.jffi.Function functionSignature signature) {
        if ( || (.incrementAndGet() <  && !"force".equalsIgnoreCase(..load()))) {
            return null;
        }
        Class<? extends NativeInvokercompiledClass;
        synchronized (this) {
            if ( == null || (compiledClass = .get()) == null) {
                compiledClass = newInvokerClass();
                if (compiledClass == null) {
                     = true;
                    return null;
                }
                .registerClass(thiscompiledClass);
                 = new WeakReference<Class<? extends NativeInvoker>>(compiledClass);
            }
        }
        try {
            Constructor<? extends NativeInvokercons = compiledClass.getDeclaredConstructor(RubyModule.classcom.kenai.jffi.Function.classSignature.class);
            return cons.newInstance(implementationClassfunctionsignature);
        } catch (Throwable t) {
            throw new RuntimeException(t);
        }
    }
    Class<? extends NativeInvokernewInvokerClass(JITSignature jitSignature) {
        JITMethodGenerator generator = null;
        JITMethodGenerator[] generators = {
            new FastIntMethodGenerator(),
            new FastLongMethodGenerator(),
            new FastNumericMethodGenerator(),};
        for (int i = 0; i < generators.lengthi++) {
            if (generators[i].isSupported(jitSignature)) {
                generator = generators[i];
                break;
            }
        }
        if (generator == null) {
            return null;
        }
        return new AsmClassBuilder(generatorjitSignature).build();
    }
New to GrepCode? Check out our FAQ X