X-Git-Url: http://git.megacz.com/?p=nestedvm.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fnestedvm%2FCompiler.java;h=b5835ddf4089655979cc944541cf354ff51d91db;hp=c68e5cf0914409db491b4d138e34d4e6fe12f335;hb=4cc48f20c2927ad6d88f4d54e10b5fe46fcef2df;hpb=9a641039c47c2619982213501f49e1168fcdbda2 diff --git a/src/org/ibex/nestedvm/Compiler.java b/src/org/ibex/nestedvm/Compiler.java index c68e5cf..b5835dd 100644 --- a/src/org/ibex/nestedvm/Compiler.java +++ b/src/org/ibex/nestedvm/Compiler.java @@ -50,8 +50,6 @@ public abstract class Compiler implements Registers { protected boolean assumeTailCalls = true; - protected boolean optimizedMemcpy = true; - // True to insert some code in the output to help diagnore compiler problems protected boolean debugCompiler = false; @@ -79,22 +77,13 @@ public abstract class Compiler implements Registers { protected boolean onePage; protected void pageSizeInit() throws Exn { - try { - Runtime.checkPageSize(pageSize,totalPages); - } catch(IllegalArgumentException e) { - throw new Exn(e.getMessage()); - } + if((pageSize&(pageSize-1)) != 0) throw new Exn("pageSize not a multiple of two"); + if((totalPages&(totalPages-1)) != 0) throw new Exn("totalPages not a multiple of two"); while(pageSize>>>pageShift != 1) pageShift++; } - /** The address of the memcpy function in the binary (used for optimizedMemcpy) */ - protected int memcpy; - - /** The address of the memset function in the binary (used for optimizedMemcpy) */ - protected int memset; - /** A set of all addresses that can be jumped too (only available if pruneCases == true) */ - protected Set jumpableAddresses; + protected Hashtable jumpableAddresses; /** Some important symbols */ ELF.Symbol userInfo, gp; @@ -216,22 +205,15 @@ public abstract class Compiler implements Registers { if(symtab == null) throw new Exn("Binary has no symtab (did you strip it?)"); ELF.Symbol sym; - // Check for some functions we can override - sym = symtab.getGlobalSymbol("memcpy"); - memcpy = sym == null ? -1 : sym.addr; - - sym = symtab.getGlobalSymbol("memset"); - memset = sym == null ? -1 : sym.addr; - userInfo = symtab.getGlobalSymbol("user_info"); gp = symtab.getGlobalSymbol("_gp"); if(gp == null) throw new Exn("no _gp symbol (did you strip the binary?)"); if(pruneCases) { // Find all possible branches - jumpableAddresses = new HashSet(); + jumpableAddresses = new Hashtable(); - jumpableAddresses.add(new Integer(elf.header.entry)); + jumpableAddresses.put(new Integer(elf.header.entry),Boolean.TRUE); ELF.SHeader text = elf.sectionWithName(".text"); if(text == null) throw new Exn("No .text segment"); @@ -262,13 +244,13 @@ public abstract class Compiler implements Registers { _go(); } - private void findBranchesInSymtab(ELF.Symtab symtab, Set jumps) { + private void findBranchesInSymtab(ELF.Symtab symtab, Hashtable jumps) { ELF.Symbol[] symbols = symtab.symbols; int n=0; for(int i=0;i= base && t < base+size) { - if(jumps.add(new Integer(t))) { + if(jumps.put(new Integer(t),Boolean.TRUE) == null) { //System.err.println("Possible jump to " + toHex(t) + " (" + inter.sourceLine(t) + ") from " + toHex(pc) + " (" + inter.sourceLine(pc) + ")"); n++; } @@ -354,7 +336,7 @@ public abstract class Compiler implements Registers { case 17: // FPU Instructions switch(rs) { case 8: // BC1F, BC1T - if(jumps.add(new Integer(pc+branchTarget*4+4))) n++; + if(jumps.put(new Integer(pc+branchTarget*4+4),Boolean.TRUE) == null) n++; break; } break; @@ -364,13 +346,13 @@ public abstract class Compiler implements Registers { if(printStats) System.err.println("Found " + n + " additional possible branch targets in Text segment"); } - private void findBranchesInData(DataInputStream dis, int size, Set jumps, int textStart, int textEnd) throws IOException { + private void findBranchesInData(DataInputStream dis, int size, Hashtable jumps, int textStart, int textEnd) throws IOException { int count = size/4; int n=0; for(int i=0;i= textStart && word < textEnd) { - if(jumps.add(new Integer(word))) { + if(jumps.put(new Integer(word),Boolean.TRUE) == null) { //System.err.println("Added " + toHex(word) + " as possible branch target (fron data segment)"); n++; } @@ -406,7 +388,7 @@ public abstract class Compiler implements Registers { public void set(Object val) { if(field == null) return; try { - field.setAccessible(true); + /*field.setAccessible(true); NOT in JDK 1.1 */ field.set(Compiler.this,val); } catch(IllegalAccessException e) { System.err.println(e); @@ -415,7 +397,7 @@ public abstract class Compiler implements Registers { public Object get() { if(field == null) return null; try { - field.setAccessible(true); + /*field.setAccessible(true); NOT in JDK 1.1 */ return field.get(Compiler.this); } catch(IllegalAccessException e) { System.err.println(e); return null;