X-Git-Url: http://git.megacz.com/?p=nestedvm.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fnestedvm%2FRuntime.java;h=63e8835977270b484256e170aaa2714cac52d610;hp=b7903741ceed0e707314af31e5d257f22bbbea9b;hb=7e1e0dc49707b777e71e69c23c0a48e0a2665a4b;hpb=897fa3c89674460aa4fad275f263cea2b341420d diff --git a/src/org/ibex/nestedvm/Runtime.java b/src/org/ibex/nestedvm/Runtime.java index b790374..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<