Commit 3da68c85 authored by Yi Lin's avatar Yi Lin

trying to imporve code patching performance

parent 9c3ea0c5
......@@ -23,6 +23,7 @@ import org.jikesrvm.runtime.Magic;
import org.jikesrvm.runtime.StackBrowser;
import org.jikesrvm.runtime.Statics;
import org.jikesrvm.scheduler.RVMThread;
import org.vmmagic.pragma.Inline;
import org.vmmagic.pragma.Interruptible;
import org.vmmagic.pragma.Uninterruptible;
import org.vmmagic.pragma.Unpreemptible;
......@@ -106,16 +107,17 @@ public abstract class CompiledMethod {
static final byte NOP = (byte) 0x90;
@Uninterruptible
@Inline
public final void nop2int() {
int instrSize = instructions.length();
for (int i = 0; i < ypOffsetsIndex; i++) {
if (ypOffsets[i] >= instrSize) {
VM.sysWriteln("for method cmid:", getId());
VM.sysWriteln("instructions.length=", instrSize);
VM.sysWriteln("ypOffsets[i]=", ypOffsets[i]);
VM.sysFail("patching code that is not code!");
}
// if (ypOffsets[i] >= instrSize) {
// VM.sysWriteln("for method cmid:", getId());
// VM.sysWriteln("instructions.length=", instrSize);
// VM.sysWriteln("ypOffsets[i]=", ypOffsets[i]);
// VM.sysFail("patching code that is not code!");
// }
instructions.set(ypOffsets[i], INT3);
}
}
......@@ -152,6 +154,7 @@ public abstract class CompiledMethod {
}
@Uninterruptible
@Inline
public final void int2nop() {
for (int i = 0; i < ypOffsetsIndex; i++) {
instructions.set(ypOffsets[i], NOP);
......
......@@ -28,6 +28,7 @@ import org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod;
import org.jikesrvm.jni.JNICompiledMethod;
import org.jikesrvm.runtime.Magic;
import org.jikesrvm.runtime.Memory;
import org.jikesrvm.scheduler.YieldpointStatistics;
import org.vmmagic.pragma.Uninterruptible;
import org.vmmagic.unboxed.Address;
......@@ -345,14 +346,16 @@ public class CompiledMethods {
if (cm == null || !cm.isCompiled())
continue;
if (cm.getId() == methodWeCare)
cm.nop2intDebug();
else cm.nop2int();
// if (cm.getId() == methodWeCare)
// cm.nop2intDebug();
// else cm.nop2int();
cm.nop2int();
patched ++;
}
long time = Magic.getTimeBase() - start;
YieldpointStatistics.methodsPatched(patched);
VM.sysWriteln("patched ", patched, " methods ");
VM.sysWriteln(" in ", time, " cycles. ");
}
......
......@@ -30,6 +30,8 @@ public class YieldpointStatistics {
// resume or probe starts, ends when all mutators end or probe ends)
public static long mutatorStartTimeMillis;
public static long mutatorTimeWithoutBlockingCost = 0;
public static int maxMethodsPatched = 0;
@Interruptible
public static void reset() {
......@@ -46,6 +48,8 @@ public class YieldpointStatistics {
mutatorTimeWithoutBlockingCost = 0;
mutatorStartTimeMillis = SysCall.sysCall.sysCurrentTimeMillis();
maxMethodsPatched = 0;
}
@Interruptible
......@@ -55,6 +59,11 @@ public class YieldpointStatistics {
if (ENABLE_YP_COUNT)
Instrumentation.disableInstrumentation();
}
public static void methodsPatched(int patched) {
if (patched > maxMethodsPatched)
maxMethodsPatched = patched;
}
@Inline
public static void takeYieldpoint() {
......@@ -77,6 +86,7 @@ public class YieldpointStatistics {
printColumn("yieldpointTurnedOnLatencySum");
printColumn("allThreadsBlockedLatencySum");
printColumn("mutatorTimeWithoutBlockingCost");
printColumn("maxMethodsPatched");
if (ENABLE_YP_COUNT) {
printColumn("yieldpointTaken");
printColumn("yieldpointExecuted");
......@@ -85,6 +95,7 @@ public class YieldpointStatistics {
printColumn(yieldpointTurnedOnLatency);
printColumn(allThreadBlockedLatency);
printColumn(mutatorTimeWithoutBlockingCost);
printColumn(maxMethodsPatched);
if (ENABLE_YP_COUNT) {
printColumn(yieldpointTaken.peek());
printColumn(AOSDatabase.yieldpointCounterData
......
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