Package kilim.analysis

Examples of kilim.analysis.Frame


                int n = getNumArgs(m); // This many will get consumed from stack
                pn("Call(" + n + "): " + m.owner + "." + m.name + m.desc);
                indent(2);
                pn("Inframe: ");
                indent(2);
                Frame f = bb.startFrame;
                pn(f.toString());
                dedent(2);
                pn("Live locals:");
                indent(2);
                Usage u = bb.getVarUsage();
                pn(u.toString());
View Full Code Here


        // Make sure the merging is fine. There used to be a bug
        assertEquals("Lkilim/test/ex/ExA;", TypeDesc.mergeType("Lkilim/test/ex/ExC;", "Lkilim/test/ex/ExD;"));
        assertEquals("Lkilim/test/ex/ExA;", TypeDesc.mergeType("Lkilim/test/ex/ExD;", "Lkilim/test/ex/ExC;"));
        BasicBlock bb = getBBForMethod(flow, "join");
        assertTrue(bb != null);
        Frame f = bb.startFrame;
        // Check Locals
        // assertEquals("Lkilim/test/ex/ExFlow;", f.getLocal(0));
        assertEquals("Lkilim/test/ex/ExA;", f.getLocal(1).getTypeDesc());
        // assertSame(D_INT, f.getLocal(2));
        // Check operand stack
        assertSame(D_BYTE, f.getStack(0).getTypeDesc());
        assertEquals("Lkilim/test/ex/ExFlow;", f.getStack(1).getTypeDesc());
        assertEquals("Lkilim/test/ex/ExA;", f.getStack(2).getTypeDesc());
    }
View Full Code Here

    public void testConstants() throws IncompatibleTypesException {
        MethodFlow flow = getFlow("loop");
        if (flow == null)
            return;
        BasicBlock bb = getBBForMethod(flow, "join");
        Frame f = bb.startFrame;
        assertSame(f.getLocal(2).getConstVal(), Value.NO_VAL);
    }
View Full Code Here

        MethodFlow flow = getFlow("kitchensink");
        if (flow == null)
            return;
        for (BasicBlock bb : flow.getBasicBlocks()) {
            if (bb.startPos == 0) {
                Frame f = bb.startFrame;
                assertEquals("Lkilim/test/ex/ExFrame;", f.getLocal(0).getTypeDesc());
                assertSame(D_INT, f.getLocal(1).getTypeDesc());
                assertSame(D_LONG, f.getLocal(2).getTypeDesc());
                // Note LONG and BOOLEAN take up two words
                assertSame(D_BOOLEAN, f.getLocal(4).getTypeDesc());
                assertSame(D_DOUBLE, f.getLocal(5).getTypeDesc());
                assertEquals("[[Ljava/lang/String;", f.getLocal(7).getTypeDesc());
            }
        }
    }
View Full Code Here

                int n = getNumArgs(m); // This many will get consumed from stack
                pn("Call(" + n + "): " + m.owner + "." + m.name + m.desc);
                indent(2);
                pn("Inframe: ");
                indent(2);
                Frame f = bb.startFrame;
                pn(f.toString());
                dedent(2);
                pn("Live locals:");
                indent(2);
                Usage u = bb.getVarUsage();
                pn(u.toString());
View Full Code Here

            }
        }
    }

    public void testStack() {
        Frame f = new Frame(1, 4);
        f.push(Value.make(0, D_LONG));
        f.push(Value.make(0, D_DOUBLE));
        f.push(Value.make(0, D_ARRAY_BOOLEAN));
        f.push(Value.make(0, D_RETURN_ADDRESS));
        f.pop();
        f.pop();
        f.pop();
        assertSame(D_LONG, f.pop().getTypeDesc());
    }
View Full Code Here

        f.pop();
        assertSame(D_LONG, f.pop().getTypeDesc());
    }

    public void testLocals() {
        Frame f = new Frame(4, 1);
        f.setLocal(0, Value.make(10, D_LONG));
        f.setLocal(2, Value.make(12, D_DOUBLE));
        f.setLocal(0, Value.make(20, D_INT));
        f.setLocal(1, Value.make(31, D_STRING));
        assertSame(D_INT, f.getLocal(0).getTypeDesc());
        assertSame(D_STRING, f.getLocal(1).getTypeDesc());
        assertSame(D_DOUBLE, f.getLocal(2).getTypeDesc());
    }
View Full Code Here

        assertSame(D_STRING, f.getLocal(1).getTypeDesc());
        assertSame(D_DOUBLE, f.getLocal(2).getTypeDesc());
    }

    public void testMergeUnchangedTypes() {
        Frame f = new Frame(4, 4);
        f.setLocal(1, Value.make(0, D_INT));
        f.setLocal(2, Value.make(0, "[Ljava/lang/Object;"));
        f.setLocal(3, Value.make(0, "Ljava/lang/reflect/AccessibleObject;"));
        f.push(Value.make(0, "Ljava/lang/Object;"));

        Frame g = new Frame(4, 4);
        g.setLocal(1, Value.make(0, D_INT));
        g.setLocal(2, Value.make(0, "[Ljava/lang/Object;"));
        g.setLocal(3, Value.make(0, "Ljava/lang/reflect/Field;"));
        g.push(Value.make(0, "Ljava/io/Serializable;"));
        Usage usage = new Usage(4);
        usage.setLiveIn(1);
        usage.setLiveIn(2);
        usage.setLiveIn(3);
        assertEquals(f, f.merge(g, /* localsOnly= */false, usage));
View Full Code Here

        usage.setLiveIn(3);
        assertEquals(f, f.merge(g, /* localsOnly= */false, usage));
    }

    public void testMergeChangedTypes() {
        Frame f = new Frame(4, 4);
        f.setLocal(0, Value.make(0, D_INT));
        f.setLocal(1, Value.make(0, "Ljava/lang/reflect/Field;"));
        f.setLocal(2, Value.make(0, "[Ljava/lang/Object;"));
        f.push(Value.make(0, "Ljava/io/Serializable;"));

        Frame g = new Frame(4, 4);
        g.setLocal(0, Value.make(0, D_INT));
        g.setLocal(1, Value.make(0, "Ljava/lang/reflect/AccessibleObject;"));
        g.setLocal(2, Value.make(0, "[Ljava/lang/Object;"));
        g.push(Value.make(0, "Ljava/lang/Object;"));

        Usage usage = new Usage(4);
        for (int i = 0; i < 4; i++)
            usage.setLiveIn(i);
        Frame h = f.merge(g, /* localsOnly= */false, usage);
        assertNotSame(f, h);
        for (int i = 0; i < 4; i++) {
            assertEquals(g.getLocal(i), h.getLocal(i));
        }
    }
View Full Code Here

            assertEquals(g.getLocal(i), h.getLocal(i));
        }
    }

    public void testMergeUnchangedIfNoUsage() {
        Frame f = new Frame(4, 4);
        f.setLocal(0, Value.make(0, D_RETURN_ADDRESS));
        f.setLocal(1, Value.make(0, D_INT));
        f.setLocal(2, Value.make(0, D_DOUBLE));

        Frame g = new Frame(4, 4);
        g.setLocal(0, Value.make(0, D_INT));
        g.setLocal(1, Value.make(0, D_DOUBLE));
        g.setLocal(3, Value.make(0, D_THROWABLE));

        Usage noUsage = new Usage(4); // default, everything is untouched.
        assertSame(f, f.merge(g, /* localsOnly= */true, noUsage));

        for (int i = 0; i < 4; i++) {
View Full Code Here

TOP

Related Classes of kilim.analysis.Frame

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.