-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
94 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ion/src/main/kotlin/cmu/pasta/fray/instrumentation/visitors/ThreadHashCodeInstrumenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package cmu.pasta.fray.instrumentation.visitors | ||
|
||
import cmu.pasta.fray.runtime.Runtime | ||
import org.objectweb.asm.ClassVisitor | ||
import org.objectweb.asm.MethodVisitor | ||
import org.objectweb.asm.Opcodes.ASM9 | ||
import org.objectweb.asm.Type | ||
import org.objectweb.asm.commons.AdviceAdapter | ||
|
||
class ThreadHashCodeInstrumenter(cv: ClassVisitor) : ClassVisitor(ASM9, cv) { | ||
override fun visitMethod( | ||
access: Int, | ||
name: String, | ||
descriptor: String, | ||
signature: String?, | ||
exceptions: Array<out String>? | ||
): MethodVisitor { | ||
return object : | ||
AdviceAdapter( | ||
ASM9, | ||
super.visitMethod(access, name, descriptor, signature, exceptions), | ||
access, | ||
name, | ||
descriptor) { | ||
override fun visitMethodInsn( | ||
opcodeAndSource: Int, | ||
owner: String, | ||
name: String, | ||
descriptor: String, | ||
isInterface: Boolean | ||
) { | ||
if (name == "hashCode" && owner == "java/lang/Object") { | ||
invokeStatic( | ||
Type.getObjectType(Runtime::class.java.name.replace(".", "/")), | ||
Utils.kFunctionToASMMethod(Runtime::onThreadHashCode), | ||
) | ||
} else { | ||
super.visitMethodInsn(opcodeAndSource, owner, name, descriptor, isInterface) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters