コード例 #1
0
ファイル: Mutator.java プロジェクト: jaggerlink/cs356
 /**
  * Mutator-specific handling of uncaught exceptions.
  *
  * @param t
  * @param e
  */
 public void uncaughtException(Thread t, Throwable e) {
   if (e.getClass() == expectedThrowable) {
     System.err.println(
         "Mutator "
             + context.getId()
             + " exiting due to expected exception of class "
             + expectedThrowable);
     expectedThrowable = null;
     end();
   } else {
     System.err.print("Mutator " + context.getId() + " caused unexpected exception: ");
     e.printStackTrace();
     System.exit(1);
   }
 }
コード例 #2
0
ファイル: Mutator.java プロジェクト: jaggerlink/cs356
  /**
   * Store a value into a reference field of an object.
   *
   * @param object The object to store the field of.
   * @param index The field index.
   * @param value The value to store.
   */
  public void storeReferenceField(ObjectReference object, int index, ObjectReference value) {
    int limit = ObjectModel.getRefs(object);
    if (Trace.isEnabled(Item.STORE) || ObjectModel.isWatched(object)) {
      Trace.printf(
          Item.STORE,
          "[%s].object[%d/%d] = %s",
          ObjectModel.getString(object),
          index,
          limit,
          value.toString());
    }
    check(!object.isNull(), "Object can not be null");
    check(index >= 0, "Index must be non-negative");
    check(index < limit, "Index " + index + " out of bounds " + limit);

    Address referenceSlot = ObjectModel.getRefSlot(object, index);
    if (ActivePlan.constraints.needsWriteBarrier()) {
      context.writeBarrier(object, referenceSlot, value, null, null, Plan.AASTORE_WRITE_BARRIER);
      if (gcEveryWB) {
        gc();
      }
    } else {
      referenceSlot.store(value);
    }
  }
コード例 #3
0
ファイル: Mutator.java プロジェクト: jaggerlink/cs356
  /**
   * Load and return the value of a reference field of an object.
   *
   * @param object The object to load the field of.
   * @param index The field index.
   */
  public ObjectReference loadReferenceField(ObjectReference object, int index) {
    int limit = ObjectModel.getRefs(object);
    check(!object.isNull(), "Object can not be null");
    check(index >= 0, "Index must be non-negative");
    check(index < limit, "Index " + index + " out of bounds " + limit);

    Address referenceSlot = ObjectModel.getRefSlot(object, index);
    ObjectReference result;
    if (ActivePlan.constraints.needsReadBarrier()) {
      result = context.readBarrier(object, referenceSlot, null, null, Plan.AASTORE_WRITE_BARRIER);
    } else {
      result = referenceSlot.loadObjectReference();
    }
    Trace.trace(
        Item.LOAD,
        "[%s].object[%d] returned [%s]",
        ObjectModel.getString(object),
        index,
        result.toString());
    return result;
  }
コード例 #4
0
ファイル: Mutator.java プロジェクト: jaggerlink/cs356
 /** Register a mutator, returning the allocated id. */
 public static synchronized void register(MutatorContext context) {
   int id = mutators.size();
   mutators.add(null);
   context.initMutator(id);
 }
コード例 #5
0
ファイル: Mutator.java プロジェクト: jaggerlink/cs356
 public void begin() {
   mutators.set(context.getId(), this);
 }