Package kilim.analysis

Examples of kilim.analysis.Value


        int numLive = 0;
        ArrayList<Value> set = new ArrayList<Value>(10);
        for (int i = 0; i < f.getMaxLocals(); i++) {
            if (u.isLiveIn(i)) {
                numLive++;
                Value v = f.getLocal(i);
                if (!set.contains(v)) set.add(v);
            }
        }
        nStack = f.getStackLen() - nStack;
        for (int i = 0; i < nStack; i++) {
            Value v = f.getStack(i);
            if (!set.contains(v)) set.add(v);
        }
        char[] sig = new char[set.size()];
        // create canonical sig. Convert types to one of 'O', 'I', 'F', 'L', 'D' and
        // put in sorted order
        // Also count non constants while we are iterating anyway.
        for (int i = 0; i < set.size(); i++) {
            Value v = set.get(i);
            char c = v.getTypeDesc().charAt(0);
            switch (c) {
                case 'L': case '[': case 'N':
                    c = 'O'; break;
                case 'I': case 'B': case 'S': case 'Z': case 'C':
                    c = 'I'; break;
                case 'J':
                    c = 'J'; break;
                case 'F':
                    c = 'F'; break;
                case 'U':
                    default: {
                    c = 'U';
                    System.err.println("***************************************");
                    System.err.println("Undefined/unrecognized value " + v);
                    System.err.println("BasicBlock:\n" + bb);
                    break;
                }
            }
            sig[i] = c;
            if (v.getConstVal() == Value.NO_VAL) {
                numNonConstants++;
            }
        }
        Arrays.sort(sig);
        numLive += nStack;
View Full Code Here


import junit.framework.TestCase;
import static kilim.Constants.*;

public class TestValue extends TestCase {
    public void testSameSiteMerge() {
        Value v = Value.make(10, D_STRING);
        v = v.merge(Value.make(20, D_OBJECT));
        Value oldV = v;
        for (int i = 0; i < 10; i++) {
            v = v.merge(Value.make(10, D_STRING));
        }
        assertSame(oldV, v);
    }
View Full Code Here

        }
        assertSame(oldV, v);
    }
   
    public void testDifferentSitesMerge() {
        Value v1 = Value.make(2, D_INT);
        Value v2 = Value.make(3, D_INT);
        Value v3 = Value.make(5, D_INT);
        Value v = v1.merge(v2);
        v = v.merge(v3);
        assertTrue(v.getNumSites() == 3);
        int[] sites = v.getCreationSites();
        int prod = 1;
        for (int i = 0; i < 3; i++) {
            prod *= sites[i];
        }
        assertTrue(prod == 30);
       
        Value oldV = v;
       
        // Ensure order of merges don't matter
        v = v3.merge(v2);
        v = v.merge(v1);
        assertEquals(v, oldV);
View Full Code Here

        assertEquals(v, oldV);
    }
   
   
    public void testTypeMerge() {
        Value v1 = Value.make(2, "Lkilim/test/ex/ExC;");
        Value v2 = Value.make(3, "Lkilim/test/ex/ExD;");
        Value v3 = Value.make(5, "Lkilim/test/ex/ExA;");
       
        Value v = v1.merge(v1);
        assertSame(v, v1);
       
        v = v1.merge(v2);
        assertEquals("Lkilim/test/ex/ExA;", v.getTypeDesc());
        v = v3.merge(v2);
        assertEquals("Lkilim/test/ex/ExA;", v.getTypeDesc());
       
        Value v4 = Value.make(7, D_INT);;
        v = v3.merge(v4);
        assertSame(D_UNDEFINED, v.getTypeDesc());
    }
View Full Code Here

        v = v3.merge(v4);
        assertSame(D_UNDEFINED, v.getTypeDesc());
    }
   
    public void testConstMerge() {
        Value v1 = Value.make(99, D_STRING, "String1");
        Value v2 = Value.make(100, D_STRING, new String("String1")); // create a new String
        Value v= v1.merge(v2);
        assertTrue(v.getConstVal().equals("String1"));
        v = v1.merge(Value.make(101, D_STRING, "Some other string"));
        assertTrue(v.getConstVal().equals(Value.NO_VAL));
    }
View Full Code Here

        int numLive = 0;
        ArrayList<Value> set = new ArrayList<Value>(10);
        for (int i = 0; i < f.getMaxLocals(); i++) {
            if (u.isLiveIn(i)) {
                numLive++;
                Value v = f.getLocal(i);
                if (!set.contains(v)) set.add(v);
            }
        }
        nStack = f.getStackLen() - nStack;
        for (int i = 0; i < nStack; i++) {
            Value v = f.getStack(i);
            if (!set.contains(v)) set.add(v);
        }
        char[] sig = new char[set.size()];
        // create canonical sig. Convert types to one of 'O', 'I', 'F', 'L', 'D' and
        // put in sorted order
        // Also count non constants while we are iterating anyway.
        for (int i = 0; i < set.size(); i++) {
            Value v = set.get(i);
            char c = v.getTypeDesc().charAt(0);
            switch (c) {
                case 'L': case '[': case 'N':
                    c = 'O'; break;
                case 'I': case 'B': case 'S': case 'Z': case 'C':
                    c = 'I'; break;
                case 'J':
                    c = 'J'; break;
                case 'F':
                    c = 'F'; break;
                case 'U':
                    default: {
                    c = 'U';
                    System.err.println("***************************************");
                    System.err.println("Undefined/unrecognized value " + v);
                    System.err.println("BasicBlock:\n" + bb);
                    break;
                }
            }
            sig[i] = c;
            if (v.getConstVal() == Value.NO_VAL) {
                numNonConstants++;
            }
        }
        Arrays.sort(sig);
        numLive += nStack;
View Full Code Here

TOP

Related Classes of kilim.analysis.Value

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.