Commit 5db2e080 authored by Yi Lin's avatar Yi Lin

?

parent 77a0726c
......@@ -12,6 +12,7 @@
*/
package org.jikesrvm.adaptive.measurements.instrumentation;
import org.jikesrvm.VM;
import org.jikesrvm.adaptive.database.AOSDatabase;
import org.jikesrvm.adaptive.measurements.RuntimeMeasurements;
import org.jikesrvm.adaptive.util.AOSOptions;
......@@ -118,6 +119,7 @@ public final class Instrumentation {
* in currently compiled methods from executing.
*/
public static void disableInstrumentation() {
VM.sysWriteln("disabled instrumentation");
instrumentationEnabled = false;
}
......@@ -126,6 +128,7 @@ public final class Instrumentation {
* perform any instrumentation.
*/
public static void enableInstrumentation() {
VM.sysWriteln("enabled instrumentation");
instrumentationEnabled = true;
}
......
......@@ -15,6 +15,7 @@ package org.jikesrvm.adaptive.measurements.instrumentation;
import org.jikesrvm.VM;
import org.jikesrvm.adaptive.measurements.Reportable;
import org.jikesrvm.compilers.opt.InstrumentedEventCounterManager;
import org.jikesrvm.compilers.opt.controlflow.YieldPoints;
/**
* An extension of StringEventCounterData so that the printing can
......@@ -100,6 +101,27 @@ public final class YieldpointCounterData extends StringEventCounterData implemen
return collectData("TRAP");
}
public double[] reportYieldpointsOfID() {
double[] ret = new double[YieldPoints.yieldpointCount];
Instrumentation.disableInstrumentation();
double total = 0;
for (String stringName : stringToCounterMap.keySet()) {
Integer counterNum = stringToCounterMap.get(stringName);
double count = getCounter(counterNum);
int start = stringName.indexOf("ID=");
if (start != -1) {
int end = stringName.indexOf(")");
int id = Integer.valueOf(stringName.substring(start+3, end));
ret[id] = count;
}
}
return ret;
}
public double reportYieldpointOfID(int id) {
return collectData("ID=" + Integer.toString(id) + ")");
}
......@@ -118,6 +140,8 @@ public final class YieldpointCounterData extends StringEventCounterData implemen
total += count;
}
// VM.sysWriteln("Reading in " + total + " for " + keyword);
return total;
}
......
......@@ -67,12 +67,14 @@ public class InsertYieldpointCounters extends CompilerPhase {
*/
@Override
public final void perform(IR ir) {
// VM.sysWriteln("Trying to perform insert yp counters");
// Don't insert counters in uninterruptible methods,
// the boot image, or when instrumentation is disabled
if (!ir.method.isInterruptible() ||
ir.method.getDeclaringClass().isInBootImage() ||
!Instrumentation.instrumentationEnabled()) {
// VM.sysWriteln("but returned");
return;
}
......@@ -129,6 +131,8 @@ public class InsertYieldpointCounters extends CompilerPhase {
// separates between method entry and backedges.
Instruction counterInst = data.
getCounterInstructionForEvent(prefix + ir.method.toString(), incrementValue);
// VM.sysWriteln("insert counter for " + prefix);
// Insert the new instruction into the code order
i.insertAfter(counterInst);
......
......@@ -3934,14 +3934,13 @@ public abstract class BaselineCompilerImpl extends BaselineCompiler implements B
}
if (YieldpointStatistics.ENABLE_YP_COUNT) {
asm.emitCALL_Abs(Magic.getTocPointer().plus(Entrypoints.baselineYieldpointCounterMethod.getOffset()));
YieldpointStatistics.yieldpointBaselineInserted++;
// asm.emitCALL_Abs(Magic.getTocPointer().plus(Entrypoints.baselineYieldpointCounterMethod.getOffset()));
// YieldpointStatistics.yieldpointBaselineInserted++;
}
// 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
|| org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_CODE_PATCHING_CALL_YP
|| org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_CODE_PATCHING_CALL_LOCAL_YP) {
ThreadLocalState.emitCompareFieldWithImm(asm, Entrypoints.takeYieldpointField.getOffset(), 0);
ForwardReference fr1;
......@@ -3977,7 +3976,10 @@ public abstract class BaselineCompilerImpl extends BaselineCompiler implements B
} else if (org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_NOP4_YP) {
asm.emitNOP(4);
}
else if (org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_NOP6_YP) {
else if (org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_NOP6_YP
|| org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_CODE_PATCHING_CALL_YP) {
int offset = asm.getMachineCodeIndex();
compiledMethod.addYPOffset(offset);
asm.emitNOP(6);
}
else if (org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_NONOP_YP) {
......
......@@ -104,8 +104,54 @@ public class YieldpointStatistics {
@Interruptible
public static void probeEnd() {
stopData();
if (ENABLE_YP_COUNT) {
showYieldpointExecutedDist();
}
printStatistics();
}
@Interruptible
public static void showYieldpointExecutedDist() {
VM.sysWriteln("reading in yp data");
double[] count = AOSDatabase.yieldpointCounterData.reportYieldpointsOfID();
VM.sysWriteln("sorting results");
// bubble sort
boolean flag = true;
double tmp;
while (flag) {
flag = false;
for (int i = 0; i < count.length - 1; i++) {
if (count[i] < count[i+1]) {
tmp = count[i];
count[i] = count[i+1];
count[i+1] = tmp;
flag = true;
}
}
}
double total = 0;
for (int i = 0; i < count.length; i++)
total += count[i];
if (total == 0)
VM.sysFail("failed to collect result");
double accumulatePercentage = 0;
for (int i = 0; i < count.length; i++) {
accumulatePercentage += (count[i] / total);
VM.sysWrite(i, ",");
VM.sysWriteln(accumulatePercentage);
if (accumulatePercentage > 0.999) {
return;
}
}
}
public static void printStatistics() {
VM.sysWriteln("============================ 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