Commit da625579 authored by Yi Lin's avatar Yi Lin

run YP COUNT on this revision

parent acbfa86c
......@@ -117,7 +117,7 @@ public final class Instrumentation {
* system shutdown. Note, this method will not stop instrumentation
* in currently compiled methods from executing.
*/
static void disableInstrumentation() {
public static void disableInstrumentation() {
instrumentationEnabled = false;
}
......@@ -125,7 +125,7 @@ public final class Instrumentation {
* Enable instrumentations, so that future compilations will not
* perform any instrumentation.
*/
static void enableInstrumentation() {
public static void enableInstrumentation() {
instrumentationEnabled = true;
}
......
......@@ -41,37 +41,51 @@ public final class YieldpointCounterData extends StringEventCounterData implemen
*/
@Override
public void report() {
// Turn off future instrumentation so that the data structures do
// not change while we are iterating over them
Instrumentation.disableInstrumentation();
VM.sysWrite("Printing " + dataName + ":\n");
VM.sysWrite("--------------------------------------------------\n");
double total = 0;
double methodEntryTotal = 0;
double backedgeTotal = 0;
for (String stringName : stringToCounterMap.keySet()) {
Integer counterNum = stringToCounterMap.get(stringName);
double count = getCounter(counterNum);
VM.sysWrite(count + " " + stringName + "\n");
total += count;
// If it's a method entry event
if (stringName.indexOf("METHOD ENTRY") != -1) {
methodEntryTotal += count;
}
if (stringName.indexOf("BACKEDGE") != -1) {
backedgeTotal += count;
}
}
VM.sysWrite("Total backedges: " + backedgeTotal + "\n");
VM.sysWrite("Method Entry Total: " + methodEntryTotal + "\n");
VM.sysWrite("Total Yieldpoints: " + total + "\n");
// // Turn off future instrumentation so that the data structures do
// // not change while we are iterating over them
// Instrumentation.disableInstrumentation();
//
// VM.sysWrite("Printing " + dataName + ":\n");
// VM.sysWrite("--------------------------------------------------\n");
// double total = 0;
// double methodEntryTotal = 0;
// double backedgeTotal = 0;
// for (String stringName : stringToCounterMap.keySet()) {
// Integer counterNum = stringToCounterMap.get(stringName);
// double count = getCounter(counterNum);
//
// VM.sysWrite(count + " " + stringName + "\n");
// total += count;
//
// // If it's a method entry event
// if (stringName.indexOf("METHOD ENTRY") != -1) {
// methodEntryTotal += count;
// }
//
// if (stringName.indexOf("BACKEDGE") != -1) {
// backedgeTotal += count;
// }
//
// }
// VM.sysWrite("Total backedges: " + backedgeTotal + "\n");
// VM.sysWrite("Method Entry Total: " + methodEntryTotal + "\n");
// VM.sysWrite("Total Yieldpoints: " + total + "\n");
}
public double reportTotalYieldpoints() {
Instrumentation.disableInstrumentation();
double total = 0;
for (String stringName : stringToCounterMap.keySet()) {
Integer counterNum = stringToCounterMap.get(stringName);
double count = getCounter(counterNum);
total += count;
}
return total;
}
}
......@@ -3931,7 +3931,7 @@ public abstract class BaselineCompilerImpl extends BaselineCompiler implements B
if (!isInterruptible) {
return;
}
// thread switch requested ??
if (org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_CHECKING_YP) {
ThreadLocalState.emitCompareFieldWithImm(asm, Entrypoints.takeYieldpointField.getOffset(), 0);
......@@ -3961,10 +3961,6 @@ public abstract class BaselineCompilerImpl extends BaselineCompiler implements B
compiledMethod.addYPOffset(asmOffset);
asm.emitNOP(1);
}
// count yieldpoint time
if (YieldpointStatistics.ENABLE_YP_COUNT)
asm.emitCALL_Abs(Magic.getTocPointer().plus(Entrypoints.yieldpointExecutedMethod.getOffset()));
if (VM.BuildForAdaptiveSystem && options.INVOCATION_COUNTERS) {
int id = compiledMethod.getId();
......
......@@ -13,6 +13,7 @@
package org.jikesrvm.compilers.opt.controlflow;
import static org.jikesrvm.compilers.opt.driver.OptConstants.INSTRUMENTATION_BCI;
import static org.jikesrvm.compilers.opt.ir.Operators.IA32_CALL;
import static org.jikesrvm.compilers.opt.ir.Operators.IR_PROLOGUE_opcode;
import static org.jikesrvm.compilers.opt.ir.Operators.YIELDPOINT_BACKEDGE;
import static org.jikesrvm.compilers.opt.ir.Operators.YIELDPOINT_EPILOGUE;
......@@ -24,10 +25,21 @@ import org.jikesrvm.VM;
import org.jikesrvm.compilers.opt.driver.CompilerPhase;
import org.jikesrvm.compilers.opt.inlining.InlineSequence;
import org.jikesrvm.compilers.opt.ir.BasicBlock;
import org.jikesrvm.compilers.opt.ir.Call;
import org.jikesrvm.compilers.opt.ir.Empty;
import org.jikesrvm.compilers.opt.ir.IR;
import org.jikesrvm.compilers.opt.ir.Instruction;
import org.jikesrvm.compilers.opt.ir.MIR_Call;
import org.jikesrvm.compilers.opt.ir.Operator;
import org.jikesrvm.compilers.opt.ir.Operators;
import org.jikesrvm.compilers.opt.ir.operand.LocationOperand;
import org.jikesrvm.compilers.opt.ir.operand.MemoryOperand;
import org.jikesrvm.compilers.opt.ir.operand.MethodOperand;
import org.jikesrvm.compilers.opt.ir.operand.Operand;
import org.jikesrvm.runtime.Entrypoints;
import org.jikesrvm.runtime.Magic;
import org.jikesrvm.scheduler.YieldpointStatistics;
import org.vmmagic.unboxed.Offset;
/**
* This class inserts yield points in
......@@ -136,7 +148,7 @@ public class YieldPoints extends CompilerPhase {
}
Instruction s = Empty.create(yp);
insertionPoint.insertBefore(s);
insertionPoint.insertBefore(s);
s.position = position;
s.bcIndex = bcIndex;
}
......
......@@ -33,6 +33,7 @@ import org.jikesrvm.compilers.opt.ir.MIR_Test;
import org.jikesrvm.compilers.opt.ir.MIR_Trap;
import org.jikesrvm.compilers.opt.ir.MIR_TrapIf;
import org.jikesrvm.compilers.opt.ir.MIR_Unary;
import org.jikesrvm.compilers.opt.ir.MIR_UnaryAcc;
import org.jikesrvm.compilers.opt.ir.MIR_UnaryNoRes;
import org.jikesrvm.compilers.opt.ir.MIR_XChng;
import org.jikesrvm.compilers.opt.ir.NullCheck;
......@@ -65,6 +66,7 @@ import static org.jikesrvm.compilers.opt.ir.Operators.IA32_JCC2_opcode;
import static org.jikesrvm.compilers.opt.ir.Operators.IA32_JMP;
import static org.jikesrvm.compilers.opt.ir.Operators.IA32_LEA_opcode;
import static org.jikesrvm.compilers.opt.ir.Operators.IA32_LOCK;
import static org.jikesrvm.compilers.opt.ir.Operators.IA32_INC;
import static org.jikesrvm.compilers.opt.ir.Operators.IA32_LOCK_CMPXCHG8B_opcode;
import static org.jikesrvm.compilers.opt.ir.Operators.IA32_LOCK_CMPXCHG_opcode;
import static org.jikesrvm.compilers.opt.ir.Operators.IA32_MOV;
......@@ -451,34 +453,17 @@ public class FinalMIRExpansion extends IRTools {
private static void expandPageProtectionReadYieldpoint(Instruction p, IR ir) {
Operand mem = MemoryOperand.BD(ir.regpool.makeTROp(), Offset.fromIntSignExtend(RVMThread.PROTECT_PAGE_OFFSET_OPT), (byte) 4, null, null);
MIR_Test.mutate(p, IA32_TEST, mem, IC(0));
if (YieldpointStatistics.ENABLE_YP_COUNT) {
genYieldpointCounter(p, ir);
}
MIR_Test.mutate(p, IA32_TEST, mem, IC(0));
}
private static void expandPageProtectionWriteYieldpoint(Instruction p, IR ir) {
Operand mem = MemoryOperand.BD(ir.regpool.makeTROp(), Offset.fromIntSignExtend(RVMThread.PROTECT_PAGE_OFFSET_OPT), (byte) 4, null, null);
MIR_Move.mutate(p, IA32_MOV, mem, IC(0));
if (YieldpointStatistics.ENABLE_YP_COUNT) {
genYieldpointCounter(p, ir);
}
}
private static void removeYieldpoint(Instruction s, IR ir) {
s.remove();
ir.MIRInfo.gcIRMap.delete(s);
if (YieldpointStatistics.ENABLE_YP_COUNT) {
genYieldpointCounter(s, ir);
}
}
private static void genYieldpointCounter(Instruction p, IR ir) {
Instruction count = MIR_Call.create0(IA32_CALL, null, null, MethodOperand.STATIC(Entrypoints.yieldpointExecutedMethod));
p.insertBefore(count);
}
/**
......@@ -594,9 +579,6 @@ public class FinalMIRExpansion extends IRTools {
Operand target = MemoryOperand.D(Magic.getTocPointer().plus(offset), (byte) 4, loc, guard);
MIR_Call.mutate0(s, CALL_SAVE_VOLATILE, null, null, target, MethodOperand.STATIC(meth));
yieldpoint.appendInstruction(s);
if (YieldpointStatistics.ENABLE_YP_COUNT) {
genYieldpointCounter(s, ir);
}
ir.MIRInfo.gcIRMap.moveToEnd(s);
yieldpoint.appendInstruction(MIR_Branch.create(IA32_JMP, nextBlock.makeJumpTarget()));
......@@ -635,9 +617,6 @@ public class FinalMIRExpansion extends IRTools {
Operand target = MemoryOperand.D(Magic.getTocPointer().plus(offset), (byte) 4, loc, guard);
MIR_Call.mutate0(s, CALL_SAVE_VOLATILE, null, null, target, MethodOperand.STATIC(meth));
yieldpoint.appendInstruction(s);
if (YieldpointStatistics.ENABLE_YP_COUNT) {
genYieldpointCounter(s, ir);
}
ir.MIRInfo.gcIRMap.moveToEnd(s);
yieldpoint.appendInstruction(MIR_Branch.create(IA32_JMP, nextBlock.makeJumpTarget()));
......
......@@ -31,9 +31,9 @@ public class Entrypoints {
//
public static final NormalMethod bootMethod = EntrypointHelper.getMethod(org.jikesrvm.VM.class, "boot", "()V");
public static final RVMMethod yieldpointExecutedMethod =
getMethod(org.jikesrvm.scheduler.YieldpointStatistics.class, "yieldpointExecuted", "()V");
//
// public static final RVMField yieldpointExecutedMethod =
// getField(org.jikesrvm.scheduler.YieldpointStatistics.class, "yieldpointExecuted", long.class);
public static final RVMMethod java_lang_reflect_Method_invokeMethod =
getMethod(java.lang.reflect.Method.class, "invoke",
......
......@@ -4034,7 +4034,9 @@ public final class RVMThread extends ThreadContext {
*/
@Unpreemptible("May block if the thread was asked to do so but otherwise does not perform actions that may lead to blocking")
public static void yieldpoint(int whereFrom, Address yieldpointServiceMethodFP) {
// VM.sysWriteln("yieldpoint reached");
if (YieldpointStatistics.ENABLE_YP_COUNT)
YieldpointStatistics.yieldpointTaken.increment();
RVMThread t = getCurrentThread();
boolean wasAtYieldpoint = t.atYieldpoint;
t.atYieldpoint = true;
......@@ -5622,15 +5624,14 @@ public final class RVMThread extends ThreadContext {
public static final Extent PROTECT_PAGE_SIZE = Extent.fromIntSignExtend(BYTES_IN_PAGE);
public void turnOnYieldpoints() {
// VM.sysWriteln("Turn on yieldpoints");
// takeYieldpoint = 1;
//
// 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) {
// Address pageAddr = Magic.objectAsAddress(this).plus(PROTECT_PAGE_OFFSET_BL).toWord().and(Word.fromIntZeroExtend(0xfffff000)).toAddress();
// Memory.mprotect(pageAddr, PROTECT_PAGE_SIZE, Memory.PROT_NONE);
// } else if (org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_CODE_PATCHING_YP) {
// CompiledMethods.setNOP2INT();
// }
takeYieldpoint = 1;
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) {
Address pageAddr = Magic.objectAsAddress(this).plus(PROTECT_PAGE_OFFSET_BL).toWord().and(Word.fromIntZeroExtend(0xfffff000)).toAddress();
Memory.mprotect(pageAddr, PROTECT_PAGE_SIZE, Memory.PROT_NONE);
} else if (org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_CODE_PATCHING_YP) {
CompiledMethods.setNOP2INT();
}
}
}
package org.jikesrvm.scheduler;
import org.jikesrvm.VM;
import org.jikesrvm.adaptive.controller.Controller;
import org.jikesrvm.adaptive.database.AOSDatabase;
import org.jikesrvm.adaptive.measurements.instrumentation.Instrumentation;
import org.jikesrvm.mm.mmtk.SynchronizedCounter;
import org.jikesrvm.runtime.SysCall;
import org.mmtk.utility.statistics.LongCounter;
......@@ -12,48 +15,47 @@ import org.vmmagic.pragma.Uninterruptible;
@Uninterruptible
public class YieldpointStatistics {
public static final boolean ENABLE_YP_COUNT = false;
// use -X:aos:insert_yieldpoint_counters with this falg
public static final boolean ENABLE_YP_COUNT = true;
// how many yieldpoints taken in total
public static SynchronizedCounter yieldpointTaken = new SynchronizedCounter();
// how many yieldpoints execute in total (including taken ones)
public static SynchronizedCounter yieldpointExecuted = new SynchronizedCounter();
public static long gcRequestBlockTime;
public static long yieldpointTurnedOnLatency = 0;
public static long allThreadBlockedLatency = 0;
// these two work together to get a mutator time (starts when all mutators resume or probe starts, ends when all mutators end or probe ends)
// these two work together to get a mutator time (starts when all mutators
// resume or probe starts, ends when all mutators end or probe ends)
public static long mutatorStartTimeMillis;
public static long mutatorTimeWithoutBlockingCost = 0;
@Interruptible
public static void reset() {
yieldpointTaken.reset();
if (ENABLE_YP_COUNT) {
yieldpointTaken.reset();
AOSDatabase.yieldpointCounterData.reset();
Instrumentation.enableInstrumentation();
}
gcRequestBlockTime = 0;
gcRequestBlockTime = 0;
yieldpointTurnedOnLatency = 0;
allThreadBlockedLatency = 0;
mutatorTimeWithoutBlockingCost = 0;
mutatorStartTimeMillis = SysCall.sysCall.sysCurrentTimeMillis();
yieldpointExecuted.reset();
}
@Interruptible
public static void stopData() {
mutatorTimeWithoutBlockingCost += SysCall.sysCall.sysCurrentTimeMillis() - mutatorStartTimeMillis;
if (ENABLE_YP_COUNT)
Instrumentation.disableInstrumentation();
}
@Inline
@Entrypoint
public static void yieldpointExecuted() {
yieldpointExecuted.increment();
}
@Inline
public static void takeYieldpoint() {
yieldpointTaken.increment();
......@@ -63,40 +65,50 @@ public class YieldpointStatistics {
public static void probeStart() {
reset();
}
@Interruptible
public static void probeEnd() {
stopData();
printStatistics();
}
public static void printStatistics() {
VM.sysWriteln("============================ Tabulate Statistics ============================");
printColumn("yieldpointTaken");
printColumn("yieldpointTurnedOnLatencySum");
printColumn("allThreadsBlockedLatencySum");
printColumn("mutatorTimeWithoutBlockingCost");
if (ENABLE_YP_COUNT) {
printColumn("yieldpointTaken");
printColumn("yieldpointExecuted");
}
printNewLine();
printColumn(yieldpointTaken.peek());
printColumn(yieldpointTurnedOnLatency);
printColumn(allThreadBlockedLatency);
printColumn(mutatorTimeWithoutBlockingCost);
if (ENABLE_YP_COUNT) {
printColumn(yieldpointTaken.peek());
printColumn(AOSDatabase.yieldpointCounterData
.reportTotalYieldpoints());
}
printNewLine();
VM.sysWriteln("------------------------------ End Tabulate Statistics -----------------------------");
}
private static void printColumn(String s) {
VM.sysWrite(s); VM.sysWrite("\t");
VM.sysWrite(s);
VM.sysWrite("\t");
}
private static void printColumn(int i) {
VM.sysWrite(i); VM.sysWrite("\t");
VM.sysWrite(i);
VM.sysWrite("\t");
}
private static void printColumn(double d) {
VM.sysWrite(d); VM.sysWrite("\t");
VM.sysWrite(d);
VM.sysWrite("\t");
}
private static void printNewLine() {
VM.sysWriteln();
}
......
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