package ex5;

import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.marker.BodyMarker;
import ch.usi.dag.disl.marker.BytecodeMarker;

public class Instrumentation {
    @Before(marker = BytecodeMarker.class, args = "new,newarray,anewarray,multianewarray")
    static void handleSafeAllocation() {
        Profiler.addSafeAllocation();
    }

    @Before(marker = BodyMarker.class, scope = "jdk.internal.misc.Unsafe.allocateInstance")
    static void handleUnsafeAllocations() {
        Profiler.addUnsafeAllocation();
    }

    @Before(marker = BodyMarker.class, scope = "sun.misc.Unsafe.allocateInstance")
    static void handleUnsafeAllocationsPraiseTheSun() {
        Profiler.addUnsafeAllocation();
    }
}
