X-Git-Url: http://git.megacz.com/?p=nestedvm.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fnestedvm%2FRuntime.java;h=63e8835977270b484256e170aaa2714cac52d610;hp=9ba3dd00d400884210676f3b324c6e0bc30e4faa;hb=7e1e0dc49707b777e71e69c23c0a48e0a2665a4b;hpb=3efa407f6606052b91cec5c98fab3f0a0a733b37 diff --git a/src/org/ibex/nestedvm/Runtime.java b/src/org/ibex/nestedvm/Runtime.java index 9ba3dd0..63e8835 100644 --- a/src/org/ibex/nestedvm/Runtime.java +++ b/src/org/ibex/nestedvm/Runtime.java @@ -135,7 +135,7 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { stackSize = max(stackSize,pageSize); stackSize = (stackSize + pageSize - 1) & ~(pageSize-1); stackPages = stackSize >>> 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 { @@ -547,6 +547,15 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { sp &= ~15; if(top - sp > 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<