Package org.jruby.util

Examples of org.jruby.util.ClassCache


    }
   
    private void jitThresholdReached(final DefaultMethod method, RubyInstanceConfig instanceConfig, final ThreadContext context, final String name) {
        try {
            // The cache is full. Abandon JIT for this method and bail out.
            ClassCache classCache = instanceConfig.getClassCache();
            if (classCache.isFull()) {
                abandonCount.incrementAndGet();
                method.setCallCount(-1);
                return;
            }
View Full Code Here


     *
     * @param loader use the provided classloader to create the cache
     * @return
     */
    public static ClassCache createClassCache(ClassLoader loader) {
        return new ClassCache(loader, new RubyInstanceConfig().getJitMax());
    }
View Full Code Here

        assertEquals(NullLoadService.class, ruby.getLoadService().getClass());
    }

    public void testSettingNewLoaderWillCreateNewClassLoader() throws Exception {
        ClassLoader beforeCL = config.getLoader();
        ClassCache beforeCC = config.getClassCache();
        config.setLoader(beforeCL);
        assertTrue("setting a new classloader that is the same, should not create a new classcache", beforeCC == config.getClassCache());

        config.setLoader(new URLClassLoader(new java.net.URL[0], beforeCL));
        assertTrue("setting a new classloader this is different, should create a new classcache", beforeCC != config.getClassCache());
View Full Code Here

        System.setProperty("jruby.compile.mode", "JIT");
        System.setProperty("jruby.jit.threshold", "0");

        // construct a new cache with thread's classloader and no limit
        ClassCache classCache = JavaEmbedUtils.createClassCache(Thread.currentThread().getContextClassLoader());
        runtime1 = JavaEmbedUtils.initialize(new ArrayList<Object>(), classCache);
        runtime2 = JavaEmbedUtils.initialize(new ArrayList<Object>(), classCache);
        evaler = JavaEmbedUtils.newRuntimeAdapter();
       
        super.setUp();
View Full Code Here

    }
   
    private DynamicMethod jitThresholdReached(final DefaultMethod method, RubyInstanceConfig instanceConfig, final ThreadContext context, final String name) {
        try {
            // The cache is full. Abandon JIT for this method and bail out.
            ClassCache classCache = instanceConfig.getClassCache();
            if (classCache.isFull()) {
                counts.abandonCount.incrementAndGet();
                method.setCallCount(-1);
                return null;
            }
View Full Code Here

        ScriptingContainer instance = new ScriptingContainer(LocalContextScope.THREADSAFE);
        instance.setError(pstream);
        instance.setOutput(pstream);
        instance.setWriter(writer);
        instance.setErrorWriter(writer);
        ClassCache result = instance.getClassCache();
        assertTrue(result.getMax() == instance.getJitMax());

        instance = null;
    }
View Full Code Here

     * Test of setClassCache method, of class ScriptingContainer.
     */
    @Test
    public void testSetClassCache() {
        logger1.info("setClassCache");
        ClassCache cache = null;
        ScriptingContainer instance = new ScriptingContainer(LocalContextScope.THREADSAFE);
        instance.setError(pstream);
        instance.setOutput(pstream);
        instance.setWriter(writer);
        instance.setErrorWriter(writer);
        instance.setClassCache(cache);
        assertEquals(cache, instance.getClassCache());

        cache = new ClassCache(instance.getProvider().getRuntime().getJRubyClassLoader(), 30);
        instance.setClassCache(cache);
        assertEquals(cache, instance.getClassCache());
        assertTrue(instance.getClassCache().getMax() == 30);

        instance = null;
View Full Code Here

        System.setProperty("jruby.compile.mode", "JIT");
        System.setProperty("jruby.jit.threshold", "0");

        // construct a new cache with thread's classloader and no limit
        ClassCache classCache = JavaEmbedUtils.createClassCache(Thread.currentThread().getContextClassLoader());
        runtime1 = JavaEmbedUtils.initialize(new ArrayList<Object>(), classCache);
        runtime2 = JavaEmbedUtils.initialize(new ArrayList<Object>(), classCache);
        evaler = JavaEmbedUtils.newRuntimeAdapter();
       
        super.setUp();
View Full Code Here

        assertEquals(NullLoadService.class, ruby.getLoadService().getClass());
    }

    public void testSettingNewLoaderWillCreateNewClassLoader() throws Exception {
        ClassLoader beforeCL = config.getLoader();
        ClassCache beforeCC = config.getClassCache();
        config.setLoader(beforeCL);
        assertTrue("setting a new classloader that is the same, should not create a new classcache", beforeCC == config.getClassCache());

        config.setLoader(new URLClassLoader(new java.net.URL[0], beforeCL));
        assertTrue("setting a new classloader this is different, should create a new classcache", beforeCC != config.getClassCache());
View Full Code Here

     *
     * @param loader use the provided classloader to create the cache
     * @return
     */
    public static ClassCache createClassCache(ClassLoader loader) {
        return new ClassCache(loader, new RubyInstanceConfig().getJitMax());
    }
View Full Code Here

TOP

Related Classes of org.jruby.util.ClassCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.