-
Notifications
You must be signed in to change notification settings - Fork 584
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
booster-cha-asm
to support ASM based CHA
- Loading branch information
1 parent
a83d7c2
commit 269c882
Showing
28 changed files
with
415 additions
and
191 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
29 changes: 29 additions & 0 deletions
29
booster-android-gradle-api/src/main/kotlin/com/didiglobal/booster/gradle/Task.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,29 @@ | ||
package com.didiglobal.booster.gradle | ||
|
||
import org.gradle.api.Task | ||
|
||
private val NOP: (String) -> Unit = {} | ||
|
||
val Task.d: (String) -> Unit | ||
get() { | ||
val debug: (String) -> Unit = logger::debug | ||
return debug.takeIf { logger.isDebugEnabled } ?: NOP | ||
} | ||
|
||
val Task.i: (String) -> Unit | ||
get() { | ||
val info: (String) -> Unit = logger::info | ||
return info.takeIf { logger.isInfoEnabled } ?: NOP | ||
} | ||
|
||
val Task.w: (String) -> Unit | ||
get() { | ||
val warn: (String) -> Unit = logger::warn | ||
return warn.takeIf { logger.isWarnEnabled } ?: NOP | ||
} | ||
|
||
val Task.e: (String) -> Unit | ||
get() { | ||
val error: (String) -> Unit = logger::error | ||
return error.takeIf { logger.isErrorEnabled } ?: NOP | ||
} |
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,3 @@ | ||
# booster-cha-asm | ||
|
||
This module provides ASM based CHA (class hierarchy analysis) implementation |
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,7 @@ | ||
apply from: "$rootDir/gradle/booster.gradle" | ||
|
||
dependencies { | ||
api project(':booster-cha') | ||
api project(':booster-transform-asm') | ||
testImplementation project(':booster-transform-asm') | ||
} |
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,3 @@ | ||
# Package com.didiglobal.booster.cha.asm | ||
|
||
提供了基于 ASM 的类继承分析 |
16 changes: 7 additions & 9 deletions
16
...oster/task/analyser/AsmClassFileParser.kt → ...bal/booster/cha/asm/AsmClassFileParser.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 |
---|---|---|
@@ -1,22 +1,20 @@ | ||
package com.didiglobal.booster.task.analyser | ||
package com.didiglobal.booster.cha.asm | ||
|
||
import com.didiglobal.booster.cha.ClassFileParser | ||
import com.didiglobal.booster.transform.asm.asClassNode | ||
import org.objectweb.asm.tree.ClassNode | ||
import java.io.InputStream | ||
|
||
internal object AsmClassFileParser : ClassFileParser<ClassNode> { | ||
object AsmClassFileParser : ClassFileParser<ClassNode> { | ||
|
||
override fun parse(input: InputStream): ClassNode { | ||
return input.asClassNode() | ||
} | ||
override fun parse(input: InputStream): ClassNode = input.asClassNode() | ||
|
||
override fun getClassName(classNode: ClassNode): String = classNode.name | ||
|
||
override fun getSuperName(classNode: ClassNode): String? = classNode.superName | ||
override fun getAccessFlags(classNode: ClassNode): Int = classNode.access | ||
|
||
override fun getInterfaces(classNode: ClassNode): Array<String> = classNode.interfaces.toTypedArray() | ||
|
||
override fun getAccessFlags(classNode: ClassNode): Int = classNode.access | ||
override fun getSuperName(classNode: ClassNode): String? = classNode.superName | ||
|
||
override fun getClassName(classNode: ClassNode): String = classNode.name | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
booster-cha-asm/src/main/kotlin/com/didiglobal/booster/cha/asm/AsmClassSet.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,9 @@ | ||
package com.didiglobal.booster.cha.asm | ||
|
||
import com.didiglobal.booster.cha.ClassSet | ||
import org.objectweb.asm.tree.ClassNode | ||
import java.io.File | ||
|
||
typealias AsmClassSet = ClassSet<ClassNode, AsmClassFileParser> | ||
|
||
fun ClassSet.Companion.from(file: File) = from(file, AsmClassFileParser) |
6 changes: 6 additions & 0 deletions
6
booster-cha-asm/src/main/kotlin/com/didiglobal/booster/cha/asm/ProgressListener.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,6 @@ | ||
package com.didiglobal.booster.cha.asm | ||
|
||
import org.objectweb.asm.tree.ClassNode | ||
import java.time.Duration | ||
|
||
typealias ProgressListener = (ClassNode, Float, Duration) -> Unit |
4 changes: 2 additions & 2 deletions
4
.../task/analyser/reference/ReferenceNode.kt → ...m/didiglobal/booster/cha/asm/Reference.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
Oops, something went wrong.