Commit d347c7a9 authored by Yi Lin's avatar Yi Lin

count yieldpoint

parent fe8bd0e9
......@@ -73,6 +73,34 @@ public final class YieldpointCounterData extends StringEventCounterData implemen
}
public double reportTotalYieldpoints() {
return collectData(null);
}
public double reportPrologueYieldpoints() {
return collectData("METHOD ENTRY");
}
public double reportBackEdgeYieldpoints() {
return collectData("BACKEDGE");
}
public double reportBaselineYieldpoints() {
return collectData("BASE");
}
public double reportO0Yieldpoints() {
return collectData("O0");
}
public double reportO1Yieldpoints() {
return collectData("O1");
}
public double reportO2Yieldpoints() {
return collectData("O2");
}
private double collectData(String keyword) {
Instrumentation.disableInstrumentation();
double total = 0;
......@@ -80,7 +108,10 @@ public final class YieldpointCounterData extends StringEventCounterData implemen
Integer counterNum = stringToCounterMap.get(stringName);
double count = getCounter(counterNum);
total += count;
if (keyword == null)
total += count;
else if (stringName.indexOf(keyword) != -1)
total += count;
}
return total;
......
......@@ -19,12 +19,14 @@ import org.jikesrvm.adaptive.controller.Controller;
import org.jikesrvm.adaptive.database.AOSDatabase;
import org.jikesrvm.adaptive.measurements.instrumentation.Instrumentation;
import org.jikesrvm.adaptive.measurements.instrumentation.YieldpointCounterData;
import org.jikesrvm.compilers.common.CompiledMethod;
import org.jikesrvm.compilers.opt.OptOptions;
import org.jikesrvm.compilers.opt.driver.CompilerPhase;
import org.jikesrvm.compilers.opt.ir.BasicBlock;
import org.jikesrvm.compilers.opt.ir.IR;
import org.jikesrvm.compilers.opt.ir.Instruction;
import org.jikesrvm.compilers.opt.ir.Operator;
import static org.jikesrvm.compilers.opt.ir.Operators.YIELDPOINT_BACKEDGE;
import static org.jikesrvm.compilers.opt.ir.Operators.YIELDPOINT_EPILOGUE;
import static org.jikesrvm.compilers.opt.ir.Operators.YIELDPOINT_PROLOGUE;
......@@ -105,6 +107,14 @@ public class InsertYieldpointCounters extends CompilerPhase {
prefix = "BACKEDGE ";
incrementValue = 1.0;
}
int compileType = ir.compiledMethod.getCompilerType();
if (compileType == CompiledMethod.BASELINE)
prefix += "(BASE) ";
else if (compileType == CompiledMethod.OPT) {
int o = ir.compiledMethod.getOptLevel();
prefix += "(O" + o + ") ";
}
// Create an instruction to increment the counter for this
// method. By appending the prefix and method name, it
......
......@@ -3933,6 +3933,10 @@ public abstract class BaselineCompilerImpl extends BaselineCompiler implements B
return;
}
if (YieldpointStatistics.ENABLE_YP_COUNT) {
asm.emitCALL_Abs(Magic.getTocPointer().plus(Entrypoints.baselineYieldpointCounterMethod.getOffset()));
}
// thread switch requested ??
if (org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_CHECKING_YP
|| org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_CODE_PATCHING_INT3_YP
......
......@@ -213,6 +213,9 @@ public class Entrypoints {
public static final NormalMethod mainThreadRunMethod =
getMethod(org.jikesrvm.scheduler.MainThread.class, "run", "()V");
public static final NormalMethod baselineYieldpointCounterMethod =
getMethod(org.jikesrvm.scheduler.YieldpointStatistics.class, "executeBaselineYP", "()V");
public static final NormalMethod yieldpointFromPrologueMethod =
getMethod(org.jikesrvm.scheduler.RVMThread.class, "yieldpointFromPrologue", "()V");
public static final NormalMethod yieldpointFromBackedgeMethod =
......
......@@ -5669,8 +5669,10 @@ public final class RVMThread extends ThreadContext {
static NoYieldpointsMonitor patchCodeLock;
static int threadsToReachYieldpoint = 0;
public void turnOnLocalYieldpoints() {
if (org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_PAGE_PROTECTION_READ_YP ||
public void turnOnLocalYieldpoints() {
if (org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_CHECKING_YP) {
takeYieldpoint = 1;
} else if (org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_PAGE_PROTECTION_READ_YP ||
org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_PAGE_PROTECTION_WRITE_YP) {
takeYieldpoint = 1;
......
......@@ -15,9 +15,12 @@ import org.vmmagic.pragma.Uninterruptible;
@Uninterruptible
public class YieldpointStatistics {
// use -X:aos:insert_yieldpoint_counters with this falg
// use -X:aos:insert_yieldpoint_counters with this flag
public static final boolean ENABLE_YP_COUNT = false;
// how many yieldpoint are executed in baseline code
public static SynchronizedCounter baselineYieldpointExecuted = new SynchronizedCounter();
// how many yieldpoints taken in total
public static SynchronizedCounter yieldpointTaken = new SynchronizedCounter();
......@@ -37,6 +40,7 @@ public class YieldpointStatistics {
public static void reset() {
if (ENABLE_YP_COUNT) {
yieldpointTaken.reset();
baselineYieldpointExecuted.reset();
AOSDatabase.yieldpointCounterData.reset();
Instrumentation.enableInstrumentation();
......@@ -64,6 +68,10 @@ public class YieldpointStatistics {
if (patched > maxMethodsPatched)
maxMethodsPatched = patched;
}
public static void executeBaselineYP() {
baselineYieldpointExecuted.increment();
}
@Inline
public static void takeYieldpoint() {
......@@ -90,6 +98,12 @@ public class YieldpointStatistics {
if (ENABLE_YP_COUNT) {
printColumn("yieldpointTaken");
printColumn("yieldpointExecuted");
printColumn("yieldpointExecutedFromPrologue");
printColumn("yieldpointExecutedFromBackedge");
printColumn("yieldpointExecutedFromBaseline");
printColumn("yieldpointExecutedFromO0");
printColumn("yieldpointExecutedFromO1");
printColumn("yieldpointExecutedFromO2");
}
printNewLine();
printColumn(yieldpointTurnedOnLatency);
......@@ -98,8 +112,14 @@ public class YieldpointStatistics {
printColumn(maxMethodsPatched);
if (ENABLE_YP_COUNT) {
printColumn(yieldpointTaken.peek());
printColumn(AOSDatabase.yieldpointCounterData
.reportTotalYieldpoints());
printColumn(AOSDatabase.yieldpointCounterData.reportTotalYieldpoints());
printColumn(AOSDatabase.yieldpointCounterData.reportPrologueYieldpoints());
printColumn(AOSDatabase.yieldpointCounterData.reportBackEdgeYieldpoints());
// printColumn(AOSDatabase.yieldpointCounterData.reportBaselineYieldpoints());
printColumn((double)baselineYieldpointExecuted.peek());
printColumn(AOSDatabase.yieldpointCounterData.reportO0Yieldpoints());
printColumn(AOSDatabase.yieldpointCounterData.reportO1Yieldpoints());
printColumn(AOSDatabase.yieldpointCounterData.reportO2Yieldpoints());
}
printNewLine();
VM.sysWriteln("------------------------------ End Tabulate Statistics -----------------------------");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment