001 package edu.rice.cs.cunit.instrumentors; 002 003 import edu.rice.cs.cunit.instrumentors.util.CompoundStrategy; 004 import edu.rice.cs.cunit.instrumentors.delay.*; 005 006 import java.util.List; 007 008 /** 009 * Compound instrumentor for executing programs with inserted random yields. 010 * @author Mathias Ricken 011 */ 012 public class CompoundYieldStrategy extends CompoundStrategy { 013 /** 014 * Create a new compound instrumentor for instrumenting regular classes. 015 * @param parameters parameters for the instrumentors 016 */ 017 public CompoundYieldStrategy(List<String> parameters) { 018 super(parameters); 019 getCombined().add(new SynchronizedMethodToBlockStrategy()); // convert synchronized methods to blocks 020 getCombined().add(new CallOnThreadStartStrategy("edu/rice/cs/cunit/SyncPointBuffer", "yieldThreadStart", 021 "edu/rice/cs/cunit/SyncPointBuffer", "RANDOM_YIELD_THREAD_START")); // instrument java.lang.Thread.start for yields 022 getCombined().add(new CallOnThreadExitStrategy("edu/rice/cs/cunit/SyncPointBuffer", "yieldThreadExit", 023 "edu/rice/cs/cunit/SyncPointBuffer", "RANDOM_YIELD_THREAD_EXIT")); // instrument java.lang.Thread.exit for yields 024 getCombined().add(new CallOnThreadRunStrategy("edu/rice/cs/cunit/SyncPointBuffer", "randomYield", 025 "edu/rice/cs/cunit/SyncPointBuffer", "RANDOM_YIELD_THREAD_RUN")); // instrument java.lang.Thread.run for yields 026 getCombined().add(new CallOnThreadJoinStrategy("edu/rice/cs/cunit/SyncPointBuffer", "randomYield", 027 "edu/rice/cs/cunit/SyncPointBuffer", "RANDOM_YIELD_THREAD_JOIN")); // instrument java.lang.Thread.join for yields 028 getCombined().add(new CallOnObjectNotifyStrategy("edu/rice/cs/cunit/SyncPointBuffer", "randomYield", 029 "edu/rice/cs/cunit/SyncPointBuffer", "RANDOM_YIELD_PRE_NOTIFY", 030 "edu/rice/cs/cunit/SyncPointBuffer", "RANDOM_YIELD_POST_NOTIFY")); // add yields before calls to java.lang.Object.notify/notifyAll 031 getCombined().add(new CallOnObjectWaitStrategy("edu/rice/cs/cunit/SyncPointBuffer", "randomYield", 032 "edu/rice/cs/cunit/SyncPointBuffer", "RANDOM_YIELD_PRE_WAIT", 033 "edu/rice/cs/cunit/SyncPointBuffer", "RANDOM_YIELD_POST_WAIT")); // add yields before calls to java.lang.Object.wait 034 getCombined().add(new CallOnSynchronizedBlockStrategy("edu/rice/cs/cunit/SyncPointBuffer", "randomYield", 035 "edu/rice/cs/cunit/SyncPointBuffer", "RANDOM_YIELD_PRE_MONITOR", 036 "edu/rice/cs/cunit/SyncPointBuffer", "RANDOM_YIELD_POST_MONITOR")); // instrument monitorenter for yields 037 } 038 }