com.apple.jobjc.JObjCRuntime.Width Java Examples

The following examples show how to use com.apple.jobjc.JObjCRuntime.Width. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StructOffsetResolverBigBang.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override protected void _resolve(final Collection<Framework> fws) throws Exception{
    for(final Width arch : Width.values()){
        System.out.println("SORBB -- Getting Struct offsets @" + arch.toString());
        String nativeSrc = generateFileForFrameworks(fws, arch);
        String executable = compileObjC(nativeSrc, arch);
        execute(executable, new Map1<String,Object>(){
            public Object apply(String ln) {
                try {
                    processLine(ln, fws, arch);
                    return null;
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        });
    }
}
 
Example #2
Source File: StructOffsetResolverBigBang.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override protected void _resolve(final Collection<Framework> fws) throws Exception{
    for(final Width arch : Width.values()){
        System.out.println("SORBB -- Getting Struct offsets @" + arch.toString());
        String nativeSrc = generateFileForFrameworks(fws, arch);
        String executable = compileObjC(nativeSrc, arch);
        execute(executable, new Map1<String,Object>(){
            public Object apply(String ln) {
                try {
                    processLine(ln, fws, arch);
                    return null;
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        });
    }
}
 
Example #3
Source File: StructOffsetResolver.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
protected void _resolve(final Collection<Framework> fws) throws Exception{
    for(final Framework fw : fws){
        for(final Width width : Width.values()){
            System.out.println("SOR -- Getting Struct offsets @" + width + " for " + fw.name);
            String nativeSrc = generateFileForFramework(fw, width);
            String executable = compileObjC(nativeSrc, width);
            execute(executable, new Map1<String,Object>(){
                public Object apply(String ln) {
                    try {
                        processLine(ln, fws, width);
                        return null;
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
            });
        }
    }
}
 
Example #4
Source File: StructOffsetResolverBigBang.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override protected void _resolve(final Collection<Framework> fws) throws Exception{
    for(final Width arch : Width.values()){
        System.out.println("SORBB -- Getting Struct offsets @" + arch.toString());
        String nativeSrc = generateFileForFrameworks(fws, arch);
        String executable = compileObjC(nativeSrc, arch);
        execute(executable, new Map1<String,Object>(){
            public Object apply(String ln) {
                try {
                    processLine(ln, fws, arch);
                    return null;
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        });
    }
}
 
Example #5
Source File: StructOffsetResolver.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected static String compileObjC(String nativeSrc, Width arch) throws Exception {
    String execPath = nativeSrc.replace(".mm", "");
    Process p = Runtime.getRuntime().exec(new String[]{
            "llvm-g++", "-Wall", gccFlag.get(arch), "-ObjC++", "-framework", "Foundation", "-o", execPath, nativeSrc
    });
    BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream()));
    BufferedReader stderr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
    while(!isDone(p)){
        while(stdout.ready()) System.out.println(stdout.readLine());
        while(stderr.ready()) System.out.println(stderr.readLine());
    }
    p.waitFor();
    while(stdout.ready() || stderr.ready()){
        if(stdout.ready()) System.out.println(stdout.readLine());
        if(stderr.ready()) System.out.println(stderr.readLine());
    }
    if(p.exitValue() != 0)
        throw new RuntimeException("gcc did not compile '" + nativeSrc + "' successfully: " + p.exitValue());
    return execPath;
}
 
Example #6
Source File: PrimitiveCoder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override public int sizeof(Width w){
    switch(w){
        case W32: return 4;
        case W64: return 8;

    default: return -1;
    }

}
 
Example #7
Source File: StructOffsetResolver.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static <A,B> A wget(Width arch, B x32, B x64){
    switch(arch){
    case W32: return (A) x32;
    case W64: return (A) x64;
    default: throw new RuntimeException();
    }
}
 
Example #8
Source File: StructOffsetResolver.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected void processLine(String ln, Collection<Framework> fws, Width arch) throws Exception{
        System.out.println("\tSOR '" + ln + "'");
        if(ln.trim().length() == 0) return;
        Pattern stinfo = Pattern.compile("^(.*) (.*):(\\d+).*$");
        Matcher m = stinfo.matcher(ln);
        if(!m.matches()) throw new RuntimeException("Failed to parse line from exec: " + ln);
        String fwname = m.group(1);
        String stname = m.group(2);
        int stsize = Integer.parseInt(m.group(3));

        Framework fw = findFrameworkByName(fws, fwname);

        Struct st = fw.getStructByName(stname);
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        nst.sizeof.put(arch, stsize);

//        System.out.println(st.name + " : " + stsize);

        Pattern finfo = Pattern.compile(" (-?\\d+)");
        Matcher fm = finfo.matcher(ln);
        int fi = 0;
        while(fm.find()){
            NField sf = nst.fields.get(fi++);
            sf.offset.put(arch, Integer.parseInt(fm.group(1)));
//            System.out.println("\t" + sf.name + " : " + off);
        }

        TypeCache.inst().pingType(st.type);
    }
 
Example #9
Source File: PrimitiveCoder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override public int sizeof(Width w){
    switch(w){
        case W32: return 4;
        case W64: return 8;

    default: return -1;
    }

}
 
Example #10
Source File: StructOffsetResolver.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected void processLine(String ln, Collection<Framework> fws, Width arch) throws Exception{
        System.out.println("\tSOR '" + ln + "'");
        if(ln.trim().length() == 0) return;
        Pattern stinfo = Pattern.compile("^(.*) (.*):(\\d+).*$");
        Matcher m = stinfo.matcher(ln);
        if(!m.matches()) throw new RuntimeException("Failed to parse line from exec: " + ln);
        String fwname = m.group(1);
        String stname = m.group(2);
        int stsize = Integer.parseInt(m.group(3));

        Framework fw = findFrameworkByName(fws, fwname);

        Struct st = fw.getStructByName(stname);
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        nst.sizeof.put(arch, stsize);

//        System.out.println(st.name + " : " + stsize);

        Pattern finfo = Pattern.compile(" (-?\\d+)");
        Matcher fm = finfo.matcher(ln);
        int fi = 0;
        while(fm.find()){
            NField sf = nst.fields.get(fi++);
            sf.offset.put(arch, Integer.parseInt(fm.group(1)));
//            System.out.println("\t" + sf.name + " : " + off);
        }

        TypeCache.inst().pingType(st.type);
    }
 
Example #11
Source File: StructOffsetResolver.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void printStructInfos(Framework fw, Width arch, PrintWriter out){
    for(Struct st : fw.structs){
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        out.println("std::cout << \"" + fw.name + " " + st.name + "\" << ':' << sizeof("+st.name+")");
        for(NField sf : nst.fields){
            out.print("\t<< ' ' << ");
            out.println(sf.type instanceof NType.NBitfield
                      ? "-1"
                      : "offsetof("+st.name+","+sf.name+")");
        }
        out.println("\t<< std::endl;");
    }
}
 
Example #12
Source File: StructOffsetResolver.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void processLine(String ln, Collection<Framework> fws, Width arch) throws Exception{
        System.out.println("\tSOR '" + ln + "'");
        if(ln.trim().length() == 0) return;
        Pattern stinfo = Pattern.compile("^(.*) (.*):(\\d+).*$");
        Matcher m = stinfo.matcher(ln);
        if(!m.matches()) throw new RuntimeException("Failed to parse line from exec: " + ln);
        String fwname = m.group(1);
        String stname = m.group(2);
        int stsize = Integer.parseInt(m.group(3));

        Framework fw = findFrameworkByName(fws, fwname);

        Struct st = fw.getStructByName(stname);
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        nst.sizeof.put(arch, stsize);

//        System.out.println(st.name + " : " + stsize);

        Pattern finfo = Pattern.compile(" (-?\\d+)");
        Matcher fm = finfo.matcher(ln);
        int fi = 0;
        while(fm.find()){
            NField sf = nst.fields.get(fi++);
            sf.offset.put(arch, Integer.parseInt(fm.group(1)));
//            System.out.println("\t" + sf.name + " : " + off);
        }

        TypeCache.inst().pingType(st.type);
    }
 
Example #13
Source File: PrimitiveCoder.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override public int sizeof(Width w){
    switch(w){
        case W32: return 4;
        case W64: return 8;

    default: return -1;
    }

}
 
Example #14
Source File: PrimitiveCoder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override public int sizeof(Width w){
    switch(w){
        case W32: return 4;
        case W64: return 8;

    default: return -1;
    }

}
 
Example #15
Source File: PrimitiveCoder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override public int sizeof(Width w){
    return 1;
}
 
Example #16
Source File: NType.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public NField(String name, NType type, Map<Width,Integer> offset) {
    QA.nonNull(name, type, offset);
    this.name = name;
    this.type = type;
    this.offset = offset;
}
 
Example #17
Source File: NType.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public NUnion(String name, List<NField> fields, Map<Width,Integer> sizeof) {
    super(name, fields, sizeof);
    assert Fp.all(hasZeroOffsets, fields) : Utils.joinWComma(fields);
}
 
Example #18
Source File: PrimitiveCoder.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override public int sizeof(Width w){
    return 4;
}
 
Example #19
Source File: PrimitiveCoder.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override public int sizeof(Width w){
    return 4;
}
 
Example #20
Source File: PrimitiveCoder.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override public int sizeof(Width w){
    return 4;
}
 
Example #21
Source File: PrimitiveCoder.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override public int sizeof(Width w){
    return 8;
}
 
Example #22
Source File: PrimitiveCoder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override public int sizeof(Width w){
    return 4;
}
 
Example #23
Source File: PrimitiveCoder.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override public int sizeof(Width w){
    return 1;
}
 
Example #24
Source File: NType.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public NType(Map<Width, Integer> sizeof) {
    this.sizeof = sizeof;
}
 
Example #25
Source File: NType.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public NType(){
    this(new HashMap<Width, Integer>());
}
 
Example #26
Source File: NTypeMerger.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public Map<Width,Integer> mergeSizeOf(Map<Width,Integer> a, Map<Width,Integer> b) throws MergeFailed{
    return mergeMap(a, b);
}
 
Example #27
Source File: PrimitiveCoder.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override public int sizeof(Width w){
    return 2;
}
 
Example #28
Source File: PrimitiveCoder.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override public int sizeof(Width w){
    return 1;
}
 
Example #29
Source File: PrimitiveCoder.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override public int sizeof(Width w){
    return 8;
}
 
Example #30
Source File: NTypeMerger.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public Map<Width,Integer> mergeOffset(Map<Width,Integer> a, Map<Width,Integer> b) throws MergeFailed{
    return mergeMap(a, b);
}