Commit 1f99093b authored by Yi Lin's avatar Yi Lin

yp stats not working, code patching not working. cant compile

parent 6be3a61a
......@@ -3955,6 +3955,10 @@ public abstract class BaselineCompilerImpl extends BaselineCompiler implements B
asm.emitTEST_Abs_Imm(RVMThread.PROTECT_GLOBAL_PAGE_BL, 0);
} else if (org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_PAGE_PROTECTION_WRITE_YP) {
asm.emitMOV_Abs_Imm(RVMThread.PROTECT_GLOBAL_PAGE_BL, 0);
} else if (org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_CODE_PATCHING_YP) {
int asmOffset = asm.getMachineCodeIndex();
compiledMethod.addYPOffset(asmOffset);
asm.emitNOP(1);
}
if (VM.BuildForAdaptiveSystem && options.INVOCATION_COUNTERS) {
......
......@@ -81,6 +81,37 @@ public abstract class CompiledMethod {
* The compiled machine code for said method.
*/
protected CodeArray instructions;
public static final int MAX_YP = 128;
public int[] ypOffsets = new int[MAX_YP];
public int ypOffsetsIndex = 0;
@Uninterruptible
public final void addYPOffset(int offset) {
if (ypOffsetsIndex < MAX_YP) {
ypOffsets[ypOffsetsIndex] = offset;
ypOffsetsIndex ++;
} else {
VM.sysFail("increase MAX_YP in CompiledMethod");
}
}
static final byte INT3 = (byte) 0xcc;
static final byte NOP = (byte) 0x90;
@Uninterruptible
public final void nop2int() {
for (int i = 0; i < ypOffsetsIndex; i++) {
instructions.set(i, INT3);
}
}
@Uninterruptible
public final void int2nop() {
for (int i = 0; i < ypOffsetsIndex; i++) {
instructions.set(i, NOP);
}
}
/**
* the offset of instructions in JTOC, for osr-special compiled
......
......@@ -330,4 +330,26 @@ public class CompiledMethods {
}
}
}
@Uninterruptible
public static void setNOP2INT() {
for (int i = 0, n = numCompiledMethods(); i < n; i ++) {
CompiledMethod cm = getCompiledMethodUnchecked(i);
if (cm == null || !cm.isCompiled())
continue;
cm.nop2int();
}
}
@Uninterruptible
public static void setINT2NOP() {
for (int i = 0, n = numCompiledMethods(); i < n; i ++) {
CompiledMethod cm = getCompiledMethodUnchecked(i);
if (cm == null || !cm.isCompiled())
continue;
cm.int2nop();
}
}
}
......@@ -3787,7 +3787,17 @@ public final class RVMThread extends ThreadContext {
@NoCheckStore
@Unpreemptible
public static void blockAllMutatorsForGC() {
turnOnYieldpoints();
if (YieldpointStatistics.ENABLED) {
YieldpointStatistics.gcRequestBlockTime = Magic.getTimeBase();
}
turnOnYieldpoints();
if (YieldpointStatistics.ENABLED) {
long turnOnLatency = (Magic.getTimeBase() - YieldpointStatistics.gcRequestBlockTime);
if (turnOnLatency < 0)
turnOnLatency = 0;
YieldpointStatistics.yieldpointTurnedOnLatency += turnOnLatency;
}
RVMThread.handshakeLock.lockNoHandshake();
while (true) {
......@@ -3836,6 +3846,10 @@ public final class RVMThread extends ThreadContext {
// Deal with terminating threads to ensure that all threads are either dead to MMTk or stopped above.
RVMThread.processAboutToTerminate();
if (YieldpointStatistics.ENABLED) {
YieldpointStatistics.allThreadBlockedLatency += (Magic.getTimeBase() - YieldpointStatistics.gcRequestBlockTime);
}
turnOffYieldpoints();
}
......@@ -5617,6 +5631,8 @@ public final class RVMThread extends ThreadContext {
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) {
Memory.mprotect(PROTECT_GLOBAL_PAGE_BL, 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();
}
}
......@@ -5625,6 +5641,8 @@ public final class RVMThread extends ThreadContext {
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) {
Memory.mprotect(PROTECT_GLOBAL_PAGE_BL, PROTECT_PAGE_SIZE, Memory.PROT_EXEC | Memory.PROT_READ | Memory.PROT_WRITE);
} else if (org.mmtk.vm.VM.config.YIELDPOINT_IMPL == org.mmtk.vm.Config.USE_CODE_PATCHING_YP) {
CompiledMethods.setINT2NOP();
}
}
}
package org.jikesrvm.scheduler;
import org.jikesrvm.VM;
import org.jikesrvm.mm.mmtk.SynchronizedCounter;
import org.vmmagic.pragma.Inline;
import org.vmmagic.pragma.Interruptible;
import org.vmmagic.pragma.Uninterruptible;
@Uninterruptible
public class YieldpointStatistics {
public static final boolean ENABLED = true;
// how many yieldpoints taken in total
public static SynchronizedCounter yieldpointTaken = new SynchronizedCounter();
public static long gcRequestBlockTime;
public static long yieldpointTurnedOnLatency;
public static long allThreadBlockedLatency;
public static void reset() {
yieldpointTaken.reset();
gcRequestBlockTime = 0;
yieldpointTurnedOnLatency = 0;
allThreadBlockedLatency = 0;
}
@Inline
public static void takeYieldpoint() {
yieldpointTaken.increment();
}
@Interruptible
public static void probeStart() {
reset();
}
@Interruptible
public static void probeEnd() {
printStatistics();
}
public static void printStatistics() {
VM.sysWriteln("============================ Tabulate Statistics ============================");
printColumn("yieldpointTaken");
printColumn("yieldpointTurnedOnLatencySum");
printColumn("allThreadsBlockedLatencySum");
printNewLine();
printColumn(yieldpointTaken.peek());
printColumn(yieldpointTurnedOnLatency);
printColumn(allThreadBlockedLatency);
printNewLine();
VM.sysWriteln("------------------------------ End Tabulate Statistics -----------------------------");
}
private static void printColumn(String s) {
VM.sysWrite(s); VM.sysWrite("\t");
}
private static void printColumn(int i) {
VM.sysWrite(i); VM.sysWrite("\t");
}
private static void printColumn(double d) {
VM.sysWrite(d); VM.sysWrite("\t");
}
private static void printNewLine() {
VM.sysWriteln();
}
}
......@@ -497,9 +497,13 @@ hardwareTrapHandler(int signo, siginfo_t *si, void *context)
else if (signo == SIGFPE)
isRecoverable = 1;
else if (signo == SIGTRAP)
isRecoverable = 0;
else if (signo == SIGTRAP) {
if (YIELDPOINT_IMPL == 3)
isRecoverable = 1;
else
isRecoverable = 0;
}
// alignment checking: hardware alignment exceptions are recoverable (i.e., we want to jump to the Java handler)
#ifdef RVM_WITH_ALIGNMENT_CHECKING
else if (signo == SIGBUS)
......@@ -648,6 +652,21 @@ hardwareTrapHandler(int signo, siginfo_t *si, void *context)
_exit(EXIT_STATUS_DYING_WITH_UNCAUGHT_EXCEPTION);
}
/* Test for nop yield point */
if (YIELDPOINT_IMPL == 3 && signo == 5){
/* Insert artifical stackframe at the stack top */
Address * sp = (Address *)(IA32_ESP(context) - 4);
IA32_ESP(context) = IA32_ESP(context) - 4;
// instructionFollowing = getInstructionFollowing(localInstructionAddress);
*sp = localInstructionAddress;
if (lib_verbose)
fprintf(SysTraceFile,"NOPYP handler\n");
unsigned int yieldPointHandlerAddress =
*(unsigned int *) (localJTOC + bootRecord->yieldpointFromPrologueOffset);
IA32_EIP(context) = yieldPointHandlerAddress;
return;
}
/* page protection yieldpoint */
if (YIELDPOINT_IMPL == 1 || YIELDPOINT_IMPL == 2) {
unsigned int faultAddress = (unsigned int) si->si_addr;
......
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