2023-01-02 09:46:59 +00:00
|
|
|
package ex11;
|
|
|
|
|
2023-01-11 14:17:18 +00:00
|
|
|
import ch.usi.dag.disl.annotation.Before;
|
|
|
|
import ch.usi.dag.disl.dynamiccontext.DynamicContext;
|
|
|
|
import ch.usi.dag.disl.guardcontext.ReflectionStaticContext;
|
|
|
|
import ch.usi.dag.disl.marker.BytecodeMarker;
|
|
|
|
import ch.usi.dag.disl.staticcontext.InstructionStaticContext;
|
|
|
|
import ch.usi.dag.disl.staticcontext.MethodStaticContext;
|
|
|
|
|
2023-01-02 09:46:59 +00:00
|
|
|
public class Instrumentation {
|
2023-01-11 14:17:18 +00:00
|
|
|
@Before(marker = BytecodeMarker.class, args = "invokevirtual, invokespecial, invokeinterface", guard = TemporaryGuard.class)
|
|
|
|
static void atObjectRefCallSite(final InstructionStaticContext isc,
|
|
|
|
final MethodStaticContext msc,
|
|
|
|
final ArgumentLengthStaticContext ivc,
|
|
|
|
final DynamicContext dc) {
|
|
|
|
final Object objectRef = dc.getStackValue(ivc.getArgumentLength(), Object.class);
|
|
|
|
|
|
|
|
|
|
|
|
final String callTarget = objectRef.getClass().getName().replace('.', '/')
|
|
|
|
.concat(".")
|
|
|
|
.concat(ivc.getName());
|
|
|
|
|
|
|
|
// TODO: call target signature (handle covariant return types)
|
|
|
|
|
|
|
|
Profiler.registerCall(new Profiler.CallInfo(
|
|
|
|
isc.getOpcode(),
|
|
|
|
isc.getIndex(),
|
|
|
|
msc.thisMethodFullName().concat(msc.thisMethodDescriptor()),
|
|
|
|
ivc.getInternalNameWithDescriptor(),
|
|
|
|
callTarget
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Before(marker = BytecodeMarker.class, args = "invokestatic", guard = TemporaryGuard.class)
|
|
|
|
static void atStaticCallSite(final InstructionStaticContext isc,
|
|
|
|
final MethodStaticContext msc,
|
|
|
|
final ArgumentLengthStaticContext ivc) {
|
|
|
|
Profiler.registerCall(new Profiler.CallInfo(
|
|
|
|
isc.getOpcode(),
|
|
|
|
isc.getIndex(),
|
|
|
|
msc.thisMethodFullName().concat(msc.thisMethodDescriptor()),
|
|
|
|
ivc.getInternalNameWithDescriptor(),
|
|
|
|
ivc.getInternalNameWithDescriptor()
|
|
|
|
));
|
|
|
|
}
|
2023-01-02 09:46:59 +00:00
|
|
|
}
|