--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Let's return back to JVM. At profiling phase HotSpot emits counters for gathering information how frequently each branch has been executed. Therefore, in comparison to gcc, HotSpot/C2 has an additional info which statements executes most times and which statements executes rarely. C2's codegen uses this info for emutting the fastest layout of branches.
And, back to your question. There is no need for these intrinsics in HotSpot JVM. Most of these aspects are already handled in HotSpot/C2. Nevertheless, code layout is critically important for performance, especially for such alignment-critical platform as modern x86 is.
if (lookForOneInAMillionOpportunityToMakeTonsOfMoney() == YEAH_BABY) {
tradeQuicklyBeforeAnyoneBeatsMeToIt();
Thread.thisPathShouldBeConsideredHot();
} else {
dangThisIsBoring++;
cleanFishTank.doIncrement();
rearrangeItemsInCloset.sinceIHaveNothingBetterToDoNow();
}--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsub...@googlegroups.com.
Here's a measurement of 3% improvement from applying such an annotation to one line:
https://groups.google.com/d/msg/seastar-dev/g0FD6NVQ_AI/HNRLcIMOAQAJ
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
public abstract class Trap {
public static Trap newInstance(CallSite cs) {
var clazz = return new ByteBuddy()
.subclass(Trap.class, Modifier.PUBLIC | Modifier.FINAL)
.defineMethod("getValue", Object.class, Modifier.PUBLIC | Modifier.FINAL)
.intercept(InvokeDynamic::/* some other stuff I don't remember right now*/)
.defineField("methodHandle", CallSite.class, Modifier.PUBLIC | Modifer.FINAL)
.make()
.load()
.getLoaded();
clazz.getField("methodHandle").set(null, cs);
return clazz.newInstance();
}
public abstract Object getValue();
}
public static final MutableCallSite CS = new MutableCallSite(MethodHandles.constant(Object.class, ""));
public static final Trap PEOPLE_ARE_DOING_TRICKY_REFLECTION_STUFF_DEOPTIMIZE = Trap.newInstance(CS);
public void mymethod() {
fastpath: {
if (PEOPLE_ARE_DOING_TRICKY_REFLECTION_STUFF_DEOPTIMIZE.getValue() == null) {
break fastpath;
}
// rest of code
return;
}
handleSlowpath();
}if (value instanceof Bar) {
((Bar)value).foo();
} else {
value.foo();
}