Exemple #1
0
 /**
  * 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);
   }
 }
Exemple #2
0
  /**
   * 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);
    }
  }
Exemple #3
0
  /**
   * 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;
  }
Exemple #4
0
 /** Register a mutator, returning the allocated id. */
 public static synchronized void register(MutatorContext context) {
   int id = mutators.size();
   mutators.add(null);
   context.initMutator(id);
 }
Exemple #5
0
 public void begin() {
   mutators.set(context.getId(), this);
 }