X-Git-Url: http://git.megacz.com/?p=nestedvm.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fnestedvm%2FRuntime.java;h=63e8835977270b484256e170aaa2714cac52d610;hp=2f23d1c9fa61f0fdbb9b3ac0ba3c7c41132168f6;hb=7e1e0dc49707b777e71e69c23c0a48e0a2665a4b;hpb=ba59dfdff778e2a1b0dbe38b19534a8e775f4a4b diff --git a/src/org/ibex/nestedvm/Runtime.java b/src/org/ibex/nestedvm/Runtime.java index 2f23d1c..63e8835 100644 --- a/src/org/ibex/nestedvm/Runtime.java +++ b/src/org/ibex/nestedvm/Runtime.java @@ -102,7 +102,7 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { protected abstract void setCPUState(CPUState state); protected Object clone() throws CloneNotSupportedException { - Runtime r = (Runtime) super.clone(); + Runtime r = (Runtime) super.clone(); r._byteBuf = null; r.startTime = 0; r.fds = new FD[OPEN_MAX]; @@ -111,7 +111,7 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { r.readPages = new int[totalPages][]; r.writePages = new int[totalPages][]; for(int i=0;i>> pageShift; - heapStart = (heapStart + pageSize) & ~(pageSize-1); + heapStart = (heapStart + pageSize - 1) & ~(pageSize-1); if(stackPages + STACK_GUARD_PAGES + (heapStart >>> pageShift) >= totalPages) throw new IllegalArgumentException("total pages too small"); } else { @@ -152,8 +152,8 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { if(totalPages == 1) { readPages[0] = writePages[0] = new int[pageSize>>2]; } else { - for(int i=(stackBottom >>> pageShift);i>2]; + for(int i=(stackBottom >>> pageShift);i>2]; } } @@ -505,8 +505,8 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { } static String[] concatArgv(String argv0, String[] rest) { - String[] argv = new String[rest.length+1]; - System.arraycopy(rest,0,argv,1,rest.length); + String[] argv = new String[rest.length+1]; + System.arraycopy(rest,0,argv,1,rest.length); argv[0] = argv0; return argv; } @@ -539,14 +539,23 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { sp = top = writePages.length*(1< ARG_MAX) throw new IllegalArgumentException("args/environ too big"); + // HACK: heapStart() isn't always available when the constructor + // is run and this sometimes doesn't get initialized + if(heapEnd == 0) { + heapEnd = heapStart(); + if(heapEnd == 0) throw new Error("heapEnd == 0"); + int pageSize = writePages.length == 1 ? 4096 : (1<fdn and returns the new fs */ public final int dupFD(int fdn) { - int i; - if(fdn < 0 || fdn >= OPEN_MAX) return -1; - if(fds[fdn] == null) return -1; - for(i=0;i= OPEN_MAX) return -1; + if(fds[fdn] == null) return -1; + for(i=0;i