Package org.jnode.vm

Examples of org.jnode.vm.VmSystemClassLoader


    /**
     * @see junit.framework.TestCase#setUp()
     */
    @Before
    public void setUp() throws Exception {
        VmSystemClassLoader bib =
                new VmSystemClassLoader(new URL("file:///" + System.getProperty("classes.dir") +
                        "/"), new VmX86Architecture32());
        VmType.initializeForBootImage(bib);
        clc = bib;
    }
View Full Code Here


    public static void main(String[] args)
        throws Exception {

        final String className = (args.length > 0) ? args[0] : "java.lang.Object";
        final VmSystemClassLoader loader = new VmSystemClassLoader(new File(".").toURL(), new VmX86Architecture32());
        final VmType vmClass = loader.loadClass(className, true);

        for (int i = 0; i < vmClass.getNoDeclaredMethods(); i++) {
            TestCFG(vmClass.getDeclaredMethod(i));
        }
    }
View Full Code Here

        //VmByteCode code = loadByteCode(className, "arithOptIntx");
        //VmByteCode code = loadByteCode(className, "simpleWhile");
        //VmByteCode code = loadByteCode(className, "terniary2");

        VmX86Architecture32 arch = new VmX86Architecture32();
        VmSystemClassLoader loader = new VmSystemClassLoader(new URL[]{
            new File("core/build/classes").toURL(),
            new File("distr/build/classes").toURL(),
            new File("local/classlib").toURL()
        }, arch);
        new VmImpl("?", arch, loader.getSharedStatics(), true, loader, null);
        VmType.initializeForBootImage(loader);
        VmType<?> type = loader.loadClass(className, true);
        VmMethod arithMethod = null;
        int nMethods = type.getNoDeclaredMethods();
        for (int i = 0; i < nMethods; i += 1) {
            VmMethod method1 = type.getDeclaredMethod(i);
            if ("terniary22".equals(method1.getName())) {
//            if ("darken".equals(method1.getName())) {
                arithMethod = method1;
                break;
            }
        }
        VmMethod method = arithMethod;
        VmByteCode code = method.getBytecode();
        //VmByteCode code = loadByteCode(className, "appel");

        EntryPoints context = new EntryPoints(loader, VmUtils.getVm().getHeapManager(), 1);
        X86CompilerHelper helper = new X86CompilerHelper(os, null, context, true);
        CompiledMethod cm = new CompiledMethod(1);
        TypeSizeInfo typeSizeInfo = loader.getArchitecture().getTypeSizeInfo();
        helper.setMethod(method);
        X86StackFrame stackFrame = new X86StackFrame(os, helper, method, context, cm);
        X86CodeGenerator x86cg = new X86CodeGenerator(method, os, code.getLength(), typeSizeInfo, stackFrame);

        generateCode(os, code, x86cg, stackFrame, arithMethod, typeSizeInfo);
View Full Code Here

    private static VmByteCode loadByteCode(String className, String methodName)
        throws MalformedURLException, ClassNotFoundException, InstantiationException {
        //VmSystemClassLoader vmc = new VmSystemClassLoader(new File(".").toURL(), new VmX86Architecture32());
        VmX86Architecture32 arch = new VmX86Architecture32();
        VmSystemClassLoader vmc = new VmSystemClassLoader(new URL[]{
            new File("core/build/classes").toURL(),
            new File("local/classlib").toURL()
        }, arch);
        new VmImpl("?", arch, vmc.getSharedStatics(), true, vmc, null);
        VmType<?> type = vmc.loadClass(className, true);
        VmMethod arithMethod = null;
        int nMethods = type.getNoDeclaredMethods();
        for (int i = 0; i < nMethods; i += 1) {
            VmMethod method = type.getDeclaredMethod(i);
            if (methodName.equals(method.getName())) {
View Full Code Here

        final String processorId = System.getProperty("cpu", "p5");
        final String dir = System.getProperty("classes.dir", ".");

        final VmX86Architecture arch = new VmX86Architecture32();
        final VmSystemClassLoader cl = new VmSystemClassLoader(new URL[]{new File(dir)
            .toURL()}, arch, new CompilerTest.DummyResolver());
        final IMTCompiler cmp = arch.getIMTCompiler();
        cmp.initialize(cl);
        VmType.initializeForBootImage(cl);
        final VmImpl vm = new VmImpl("?", arch, cl.getSharedStatics(), false, cl, null);
        vm.toString();

        //final ObjectResolver resolver = new DummyResolver();
        final X86CpuID cpuId = X86CpuID.createID(processorId);


        final String[] clsNames = CompilerTest.clsNames;

        final long start = System.currentTimeMillis();
        for (int k = 0; k < clsNames.length; k++) {
            final String clsName = clsNames[k];
            System.out.println("Compiling " + clsName);
            final VmType type = cl.loadClass(clsName, true);

            final Object[] tib = ((VmClassType) type).getTIB();
            final byte[] cimt = (byte[]) tib[TIBLayout.COMPILED_IMT_INDEX];
            if (cimt != null) {
                final String fname = type.getName() + ".imt.bin";
View Full Code Here

        if (archName.equals("x86_64")) {
            arch = new VmX86Architecture64();
        } else {
            arch = new VmX86Architecture32();
        }
        final VmSystemClassLoader cl = new VmSystemClassLoader(new java.net.URL[]{
            new File("./core/build/classes/").getCanonicalFile().toURI().toURL(),
            new File("./distr/build/classes/").getCanonicalFile().toURI().toURL(),
            new URL("jar:" + new File("./all/lib/classlib.jar").getCanonicalFile().toURI().toURL() + "!/"),
        }, arch);

        final VmImpl vm = new VmImpl("?", arch, cl.getSharedStatics(), false, cl, null);
        vm.toString();
        VmType.initializeForBootImage(cl);
        System.out.println("Architecture: " + arch.getFullName());

        //final ObjectResolver resolver = new DummyResolver();
        final X86CpuID cpuId = X86CpuID.createID(processorId);
        //NativeCodeCompiler c = cs[0];
        final NativeCodeCompiler[] cs = {
            //new X86Level1Compiler(),
            new X86Level1ACompiler(),
            new X86Level2Compiler()
        };
        for (int i = 0; i < cs.length; i++) {
            cs[i].initialize(cl);
        }
        long times[] = new long[cs.length];
        int counts[] = new int[cs.length];

        for (int ci = 0; ci < cs.length; ci++) {
            final long start = System.currentTimeMillis();
            for (int k = 0; k < clsNames.length; k++) {
                final String clsName = clsNames[k];
                System.out.println("Compiling " + clsName);
                final VmType type = cl.loadClass(clsName, true);
                final int cnt = type.getNoDeclaredMethods();
                for (int i = 0; i < cnt; i++) {
                    final VmMethod method = type.getDeclaredMethod(i);
                    if (
                        "<init>".equals(method.getName()) ||
View Full Code Here

            final Map<String, byte[]> resources = loadSystemResource(piRegistry);

            /* Now create the processor */
            final BaseVmArchitecture arch = getArchitecture();
            final NativeStream os = createNativeStream();
            clsMgr = new VmSystemClassLoader(null/*classesURL*/, arch,
                new BuildObjectResolver(os, this));
            blockedObjects.add(clsMgr);
            blockedObjects.add(clsMgr.getSharedStatics());
            blockedObjects.add(clsMgr.getSharedStatics().getTable());
            blockedObjects.add(clsMgr.getIsolatedStatics());
View Full Code Here

        String[] urls = classesURL.split(",");
        URL[] urla = new URL[urls.length];
        for (int i = 0; i < urls.length; i++)
            urla[i] = new URL(urls[i].trim());

        final VmSystemClassLoader cl = new VmSystemClassLoader(urla, arch);
        final Vm vm = new VmImpl("?", arch, cl.getSharedStatics(), false, cl, null);
        vm.toString(); // Just to avoid compiler warnings
        VmType.initializeForBootImage(cl);
        long lastModified = 0;

        FileWriter fw = new FileWriter(destFile);
        PrintWriter out = new PrintWriter(fw);
        out.println("; " + destFile.getPath());
        out.println("; THIS file has been generated automatically on " + new Date());
        out.println();

        for (ClassName cn : classes) {
            lastModified = Math.max(lastModified, cl.findResource(cn.getClassFileName()).
                openConnection().getLastModified());
            out.println("; Constants for " + cn.getClassName());

            if (cn.isStatic()) {
                Class<?> cls = Class.forName(cn.getClassName());
                Field fields[] = cls.getDeclaredFields();
                for (int i = 0; i < fields.length; i++) {
                    Field f = fields[i];
                    if (Modifier.isStatic(f.getModifiers()) && Modifier.isPublic(f.getModifiers())) {
                        Object value = f.get(null);
                        if (value instanceof Number) {
                            String cname = cls.getName();
                            int idx = cname.lastIndexOf('.');
                            if (idx > 0) {
                                cname = cname.substring(idx + 1);
                            }
                            String name = cname + "_" + f.getName();
                            out.println(name + " equ " + value);
                        }
                    }
                }
                out.println();
            } else {

                out.println("; VmClass: " + cn.getClassName());
                VmType<?> vmClass = cl.loadClass(cn.getClassName(), true);
                vmClass.link();
                String cname = vmClass.getName().replace('/', '.');
                int idx = cname.lastIndexOf('.');
                if (idx > 0) {
                    cname = cname.substring(idx + 1);
View Full Code Here

//            }
    }

    private static VmByteCode loadByteCode(String className)
        throws MalformedURLException, ClassNotFoundException {
        VmSystemClassLoader vmc = new VmSystemClassLoader(new File(".").toURL(), new VmX86Architecture32());
        VmType type = vmc.loadClass(className, true);
        VmMethod arithMethod = null;
        int nMethods = type.getNoDeclaredMethods();
        for (int i = 0; i < nMethods; i += 1) {
            VmMethod method = type.getDeclaredMethod(i);
            if ("const1".equals(method.getName())) {
View Full Code Here

TOP

Related Classes of org.jnode.vm.VmSystemClassLoader

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.