Example #1
0
  public Instruction execute(SystemState ss, KernelState ks, ThreadInfo th) {
    long v1 = th.longPop();
    long v2 = th.longPop();

    th.push(conditionValue(v1, v2), false);

    return getNext(th);
  }
Example #2
0
  public Instruction execute(SystemState ss, KernelState ks, ThreadInfo th) {
    int v1 = th.pop();
    int v2 = th.pop();

    th.push(v1 + v2, false);

    return getNext(th);
  }
Example #3
0
  public Instruction execute(SystemState ss, KernelState ks, ThreadInfo ti) {
    Heap heap = ti.getHeap();
    ClassInfo ci;

    try {
      ci = ClassInfo.getResolvedClassInfo(cname);

    } catch (NoClassInfoException cx) {
      // can be any inherited class or required interface
      return ti.createAndThrowException("java.lang.NoClassDefFoundError", cx.getMessage());
    }

    if (!ci.isRegistered()) {
      ci.registerClass(ti);
    }

    // since this is a NEW, we also have to pushClinit
    if (!ci.isInitialized()) {
      if (ci.initializeClass(ti)) {
        return ti.getPC(); // reexecute this instruction once we return from the clinits
      }
    }

    if (heap.isOutOfMemory()) { // simulate OutOfMemoryError
      return ti.createAndThrowException(
          "java.lang.OutOfMemoryError", "trying to allocate new " + cname);
    }

    int objRef = heap.newObject(ci, ti);
    newObjRef = objRef;

    // pushes the return value onto the stack
    ti.push(objRef, true);

    ss.checkGC(); // has to happen after we push the new object ref

    return getNext(ti);
  }
Example #4
0
  void pushArguments(ThreadInfo ti, Object[] args, Object[] attrs) {
    if (args != null) {
      for (int i = 0; i < args.length; i++) {
        Object a = args[i];
        boolean isLong = false;

        if (a != null) {
          if (a instanceof Ref) {
            ti.push(((Ref) a).getReference(), true);
          } else if (a instanceof Boolean) {
            ti.push((Boolean) a ? 1 : 0, false);
          } else if (a instanceof Integer) {
            ti.push((Integer) a, false);
          } else if (a instanceof Long) {
            ti.longPush((Long) a);
            isLong = true;
          } else if (a instanceof Double) {
            ti.longPush(Types.doubleToLong((Double) a));
            isLong = true;
          } else if (a instanceof Byte) {
            ti.push((Byte) a, false);
          } else if (a instanceof Short) {
            ti.push((Short) a, false);
          } else if (a instanceof Float) {
            ti.push(Types.floatToInt((Float) a), false);
          }
        }

        if (attrs != null && attrs[i] != null) {
          if (isLong) {
            ti.setLongOperandAttr(attrs[i]);
          } else {
            ti.setOperandAttr(attrs[i]);
          }
        }
      }
    }
  }