interpreter fixes
authorbrian <brian@brianweb.net>
Wed, 5 May 2004 17:42:50 +0000 (10:42 -0700)
committerbrian <brian@brianweb.net>
Wed, 5 May 2004 17:42:50 +0000 (10:42 -0700)
darcs-hash:20040505174250-24bed-4a77d98d7926a6d6cc515a637d898d3cba0feb50.gz

src/org/ibex/nestedvm/Interpreter.java
src/org/ibex/nestedvm/Runtime.java
src/org/ibex/nestedvm/UnixRuntime.java

index 1fcdc4b..45d433c 100644 (file)
@@ -7,7 +7,7 @@ package org.ibex.nestedvm;
 import org.ibex.nestedvm.util.*;
 import java.io.*;
 
-public class Interpreter extends UnixRuntime {
+public class Interpreter extends UnixRuntime implements Cloneable {
     // Registers
     private int[] registers = new int[32];
     private int hi,lo;
@@ -51,6 +51,13 @@ public class Interpreter extends UnixRuntime {
         }
     }
     
+    protected Object clone() throws CloneNotSupportedException {
+        Interpreter r = (Interpreter) super.clone();
+        r.registers = (int[]) registers.clone();
+        r.fpregs = (int[]) fpregs.clone();
+        return r;
+    }
+    
     // Main interpretor
     // the return value is meaningless, its just to catch people typing "return" by accident
     private final int runSome() throws FaultException,ExecutionException {
@@ -415,6 +422,9 @@ public class Interpreter extends UnixRuntime {
                     }
                     case 20: { // Integer
                         switch(subcode) {
+                            case 32: // CVT.S.W
+                                setFloat(fd,f[fs]);
+                                break;
                             case 33: // CVT.D.W
                                 setDouble(fd,f[fs]);
                                 break;
index 9ba3dd0..63e8835 100644 (file)
@@ -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<<pageShift);
+            heapEnd = (heapEnd + pageSize - 1) & ~(pageSize-1);
+        }
+
         CPUState cpuState = new CPUState();
         cpuState.r[A0] = argsAddr;
         cpuState.r[A1] = envAddr;
index 9b9a8cf..151699f 100644 (file)
@@ -306,6 +306,12 @@ public abstract class UnixRuntime extends Runtime implements Cloneable {
     private int exec(String normalizedPath, String[] argv, String[] envp) throws ErrnoException {
         if(argv.length == 0) argv = new String[]{""};
 
+        // NOTE: For this little hack to work nestedvm.root MUST be "."
+        /*try {
+            System.err.println("Execing normalized path: " + normalizedPath);
+            if(true) return exec(new Interpreter(normalizedPath),argv,envp);
+        } catch(IOException e) { throw new Error(e); }*/
+        
         Object o = gs.exec(this,normalizedPath);
         if(o == null) return -ENOENT;