Skip to content

Commit

Permalink
fmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
aoli-al committed Jun 24, 2024
1 parent 2c896f4 commit 95fe5d2
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ class ClassConstructorInstrumenter(cv: ClassVisitor) : ClassVisitor(ASM9, cv) {
if (name == "<clinit>") {
val methodSignature = "#$name$descriptor"
val eMv =
MethodEnterVisitor(mv, Runtime::onSkipMethod, access, name, descriptor, false, false, preCustomizer = {
it.push(methodSignature)
})
MethodEnterVisitor(
mv,
Runtime::onSkipMethod,
access,
name,
descriptor,
false,
false,
preCustomizer = { it.push(methodSignature) })
return MethodExitVisitor(
eMv,
Runtime::onSkipMethodDone,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import org.objectweb.asm.MethodVisitor
import org.objectweb.asm.Opcodes.ASM9
import org.objectweb.asm.Type
import org.objectweb.asm.commons.AdviceAdapter
import org.objectweb.asm.commons.GeneratorAdapter

class LockInstrumenter(cv: ClassVisitor) :
ClassVisitorBase(
Expand All @@ -32,9 +31,15 @@ class LockInstrumenter(cv: ClassVisitor) :
}
if (name == "tryLock" && descriptor == "(JLjava/util/concurrent/TimeUnit;)Z") {
val eMv =
MethodEnterVisitor(mv, Runtime::onLockTryLockInterruptibly, access, name, descriptor, true, true, postCustomizer = {
storeArg(0)
})
MethodEnterVisitor(
mv,
Runtime::onLockTryLockInterruptibly,
access,
name,
descriptor,
true,
true,
postCustomizer = { storeArg(0) })
return MethodExitVisitor(
eMv, Runtime::onLockTryLockInterruptiblyDone, access, name, descriptor, true, false, true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ class MethodHandleNativesInstrumenter(cv: ClassVisitor) :
if (name == "linkMethodHandleConstant") {
val methodSignature = "$className#$name$descriptor"
val eMv =
MethodEnterVisitor(mv, Runtime::onSkipMethod, access, name, descriptor, false, false, preCustomizer = {
it.push(methodSignature)
})
MethodEnterVisitor(
mv,
Runtime::onSkipMethod,
access,
name,
descriptor,
false,
false,
preCustomizer = { it.push(methodSignature) })
return MethodExitVisitor(
eMv, Runtime::onSkipMethodDone, access, name, descriptor, false, false, true) {
it.push(methodSignature)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ class PrintStreamInstrumenter(cv: ClassVisitor) :
if (name == "println" || name == "writeln" || name == "write") {
val methodSignature = "$className#$name$descriptor"
val eMv =
MethodEnterVisitor(mv, Runtime::onSkipMethod, access, name, descriptor, false, false, preCustomizer = {
it.push(methodSignature)
})
MethodEnterVisitor(
mv,
Runtime::onSkipMethod,
access,
name,
descriptor,
false,
false,
preCustomizer = { it.push(methodSignature) })
return MethodExitVisitor(
eMv, Runtime::onSkipMethodDone, access, name, descriptor, false, false, true) {
it.push(methodSignature)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,24 @@ class SkipMethodInstrumenter(cv: ClassVisitor) :
): MethodVisitor {
val methodSignature = "$className#$name$descriptor"
val eMv =
MethodEnterVisitor(mv, Runtime::onSkipMethod, access, name, descriptor, false, false, preCustomizer = {
push(methodSignature)
})
MethodEnterVisitor(
mv,
Runtime::onSkipMethod,
access,
name,
descriptor,
false,
false,
preCustomizer = { push(methodSignature) })
return MethodExitVisitor(
eMv, Runtime::onSkipMethodDone, access, name, descriptor, false, false, true, {
push(methodSignature)
})
eMv,
Runtime::onSkipMethodDone,
access,
name,
descriptor,
false,
false,
true,
{ push(methodSignature) })
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ class UnsafeInstrumenter(cv: ClassVisitor) : ClassVisitorBase(cv, "sun.misc.Unsa
name == "compareAndSwapLong" ||
name == "compareAndSetReference") {
return MethodEnterVisitor(
mv, Runtime::onUnsafeWriteVolatile, access, name, descriptor, false, true, preCustomizer = {
mv,
Runtime::onUnsafeWriteVolatile,
access,
name,
descriptor,
false,
true,
preCustomizer = {
if (name == "compareAndSwapLong") {
pop2()
pop2()
Expand Down Expand Up @@ -55,7 +62,14 @@ class UnsafeInstrumenter(cv: ClassVisitor) : ClassVisitorBase(cv, "sun.misc.Unsa
name == "getAndSetInt" ||
name == "getAndSetObject") {
return MethodEnterVisitor(
mv, Runtime::onUnsafeWriteVolatile, access, name, descriptor, false, true, preCustomizer = {
mv,
Runtime::onUnsafeWriteVolatile,
access,
name,
descriptor,
false,
true,
preCustomizer = {
if (name == "putLongVolatile" ||
name == "putDoubleVolatile" ||
name == "getAndAddLong" ||
Expand Down

0 comments on commit 95fe5d2

Please sign in to comment.