JVM: Reduce number of comparison on bytecode analysis merge
operations. Since these methods are hot - they are call on each branch, even such primitive optimizations should give measurable speedup.
This commit is contained in:
committed by
Space Team
parent
5e2d3737f5
commit
f16ea9dfbb
+12
-9
@@ -174,17 +174,20 @@ open class BoxingInterpreter(
|
||||
when {
|
||||
v == StrictBasicValue.UNINITIALIZED_VALUE || w == StrictBasicValue.UNINITIALIZED_VALUE ->
|
||||
StrictBasicValue.UNINITIALIZED_VALUE
|
||||
v is BoxedBasicValue && w is BoxedBasicValue -> {
|
||||
onMergeSuccess(v, w)
|
||||
when {
|
||||
v is TaintedBoxedValue -> v
|
||||
w is TaintedBoxedValue -> w
|
||||
v.type != w.type -> mergeBoxedHazardous(v, w, isLocalVariable)
|
||||
else -> v // two clean boxed values with the same type are equal
|
||||
v is BoxedBasicValue -> {
|
||||
if (w is BoxedBasicValue) {
|
||||
onMergeSuccess(v, w)
|
||||
when {
|
||||
v is TaintedBoxedValue -> v
|
||||
w is TaintedBoxedValue -> w
|
||||
v.type != w.type -> mergeBoxedHazardous(v, w, isLocalVariable)
|
||||
else -> v // two clean boxed values with the same type are equal
|
||||
}
|
||||
} else {
|
||||
mergeBoxedHazardous(v, w, isLocalVariable)
|
||||
}
|
||||
}
|
||||
v is BoxedBasicValue ->
|
||||
mergeBoxedHazardous(v, w, isLocalVariable)
|
||||
|
||||
w is BoxedBasicValue ->
|
||||
mergeBoxedHazardous(w, v, isLocalVariable)
|
||||
else ->
|
||||
|
||||
+7
-3
@@ -30,10 +30,14 @@ abstract class ReferenceTrackingInterpreter : OptimizationBasicInterpreter() {
|
||||
else
|
||||
createTaintedValue(v, w)
|
||||
|
||||
v is TrackedReferenceValue && w is TrackedReferenceValue ->
|
||||
createPossiblyMergedValue(v, w)
|
||||
v is TrackedReferenceValue -> {
|
||||
if (w is TrackedReferenceValue)
|
||||
createPossiblyMergedValue(v, w)
|
||||
else
|
||||
createTaintedValue(v, w)
|
||||
}
|
||||
|
||||
v is TrackedReferenceValue || w is TrackedReferenceValue ->
|
||||
w is TrackedReferenceValue ->
|
||||
createTaintedValue(v, w)
|
||||
|
||||
else ->
|
||||
|
||||
+15
-14
@@ -96,20 +96,21 @@ class NullabilityInterpreter(private val generationState: GenerationState) : Opt
|
||||
|
||||
override fun merge(v: BasicValue, w: BasicValue): BasicValue =
|
||||
when {
|
||||
v is NullBasicValue && w is NullBasicValue ->
|
||||
NullBasicValue
|
||||
v is NullBasicValue || w is NullBasicValue ->
|
||||
StrictBasicValue.REFERENCE_VALUE
|
||||
v is ProgressionIteratorBasicValue && w is ProgressionIteratorBasicValue ->
|
||||
mergeNotNullValuesOfSameKind(v, w)
|
||||
v is ProgressionIteratorBasicValue && w is NotNullBasicValue ->
|
||||
NotNullBasicValue.NOT_NULL_REFERENCE_VALUE
|
||||
w is ProgressionIteratorBasicValue && v is NotNullBasicValue ->
|
||||
NotNullBasicValue.NOT_NULL_REFERENCE_VALUE
|
||||
v is NotNullBasicValue && w is NotNullBasicValue ->
|
||||
mergeNotNullValuesOfSameKind(v, w)
|
||||
else ->
|
||||
super.merge(v, w)
|
||||
v === NullBasicValue -> if (w === NullBasicValue) NullBasicValue else StrictBasicValue.REFERENCE_VALUE
|
||||
|
||||
w === NullBasicValue -> StrictBasicValue.REFERENCE_VALUE
|
||||
|
||||
v is ProgressionIteratorBasicValue -> when (w) {
|
||||
is ProgressionIteratorBasicValue -> mergeNotNullValuesOfSameKind(v, w)
|
||||
is NotNullBasicValue -> NotNullBasicValue.NOT_NULL_REFERENCE_VALUE
|
||||
else -> super.merge(v, w)
|
||||
}
|
||||
v is NotNullBasicValue -> when (w) {
|
||||
is ProgressionIteratorBasicValue -> NotNullBasicValue.NOT_NULL_REFERENCE_VALUE
|
||||
is NotNullBasicValue -> mergeNotNullValuesOfSameKind(v, w)
|
||||
else -> super.merge(v, w)
|
||||
}
|
||||
else -> super.merge(v, w)
|
||||
}
|
||||
|
||||
private fun mergeNotNullValuesOfSameKind(v: StrictBasicValue, w: StrictBasicValue) =
|
||||
|
||||
Reference in New Issue
Block a user