static void noim() { int i; wr('n'); wr('i'); wr(' '); i = Native.getSP(); // sp of noim(); int sp = Native.rdIntMem(i - 4); // sp of calling function int pc = Native.rdIntMem(sp - 3) - 1; // one to high i = Native.rdIntMem(sp); // mp wrSmall(i); wr(' '); int start = Native.rdMem(i) >>> 10; wrSmall(start); wr(' '); wrByte(pc); wr(' '); int val = Native.rdMem(start + (pc >> 2)); for (i = (pc & 0x03); i < 3; ++i) val >>= 8; val &= 0xff; wrByte(val); Object o = new Object(); synchronized (o) { System.out.println(); System.out.print("JOP: bytecode "); System.out.print(val); System.out.println(" not implemented"); trace(sp); for (; ; ) ; } }
public static int[] makeHWArray(int len, int address, int idx, int cp) { int p = Native.rdMem(cp - 1); p = Native.rdMem(p + 1); p += idx * 2; Native.wrMem(address, p); Native.wrMem(len, p + 1); return Native.toIntArray(p); }
/** * Install a handle in two static fields for a hardware object * * @param o a 'real' instance of the HW object for the class reference * @param address IO address of the hardware device * @param idx index of the static fields * @param cp address of constant pool of the factory class * @return reference to the HW object */ public static Object makeHWObject(Object o, int address, int idx, int cp) { int ref = Native.toInt(o); int pcl = Native.rdMem(ref + 1); int p = Native.rdMem(cp - 1); p = Native.rdMem(p + 1); p += idx * 2; Native.wrMem(address, p); Native.wrMem(pcl, p + 1); return Native.toObject(p); }
/** Invoked on a hardware generated exception. */ static void except() { saved_sp = Native.getSP(); if (Native.rdMem(Const.IO_EXCPT) == Const.EXC_SPOV) { // reset stack pointer Native.setSP(Const.STACK_OFF); } // we have more stack available now for the stack overflow handleException(); }
/** * Create interrupt handler and preallocated exceptions in a static method instead of <clinit>. * Jikes puts <clinit> as first methods into the table (instead of interrupt()), javac as last * method. * * <p>We could use HWO here. */ static void init() { ih = new Runnable[Native.rdMem(Const.IO_CPUCNT)][Const.NUM_INTERRUPTS]; dh = new DummyHandler(); for (int core = 0; core < Native.rdMem(Const.IO_CPUCNT); ++core) { for (int var = 0; var < Const.NUM_INTERRUPTS; ++var) { JVMHelp.addInterruptHandler(core, var, dh); } } sys = IOFactory.getFactory().getSysDevice(); SOError = new StackOverflowError(); NPExc = new NullPointerException(); ABExc = new ArrayIndexOutOfBoundsException(); ArithExc = new ArithmeticException(); CCExc = new ClassCastException(); RetryExc = RetryException.instance; }
static void trace(int sp) { int fp, mp, vp, pc, addr, loc, args; int val; // for (int i=0; i<1024; ++i) { // wrSmall(i); // wrSmall(Native.rdIntMem(i)); // wr('\n'); // } wr("saved sp="); wrSmall(sp); wr('\n'); fp = sp - 4; // first frame point is easy, since last sp points to the end of the frame wr(" mp pc fp"); wr('\n'); while (fp > Const.STACK_OFF + 5) { mp = Native.rdIntMem(fp + 4); vp = Native.rdIntMem(fp + 2); pc = Native.rdIntMem(fp + 1); val = Native.rdMem(mp); addr = val >>> 10; // address of callee wrSmall(mp); // wrSmall(addr); wrSmall(pc); wrSmall(fp); wr('\n'); val = Native.rdMem(mp + 1); // cp, locals, args args = val & 0x1f; loc = (val >>> 5) & 0x1f; fp = vp + args + loc; // new fp can be calc. with vp and count of local vars } wr('\n'); }
static void handleException() { if (Const.USE_RTTM) { // abort transaction to avoid invoking f_athrow() twice Native.wrMem(Const.TM_ABORTED, Const.MEM_TM_MAGIC); } int i; i = Native.rdMem(Const.IO_EXCPT); if (i == Const.EXC_SPOV) { throw SOError; } else if (i == Const.EXC_NP) { throw NPExc; } else if (i == Const.EXC_AB) { throw ABExc; } else if (i == Const.EXC_DIVZ) { throw ArithExc; } else if (i == Const.EXC_ROLLBACK) { throw RetryExc; } for (; ; ) ; }
/** * Remove the interrupt handler * * @param nr interrupt number */ public static void removeInterruptHandler(int nr) { removeInterruptHandler(Native.rdMem(Const.IO_CPU_ID), nr); }
/** * Add a Runnable as a first level interrupt handler. Use the current core. * * @param nr interrupt number * @param r Runnable the represents the interrupt handler */ public static void addInterruptHandler(int nr, Runnable r) { addInterruptHandler(Native.rdMem(Const.IO_CPU_ID), nr, r); }