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 {
|
when {
|
||||||
v == StrictBasicValue.UNINITIALIZED_VALUE || w == StrictBasicValue.UNINITIALIZED_VALUE ->
|
v == StrictBasicValue.UNINITIALIZED_VALUE || w == StrictBasicValue.UNINITIALIZED_VALUE ->
|
||||||
StrictBasicValue.UNINITIALIZED_VALUE
|
StrictBasicValue.UNINITIALIZED_VALUE
|
||||||
v is BoxedBasicValue && w is BoxedBasicValue -> {
|
v is BoxedBasicValue -> {
|
||||||
onMergeSuccess(v, w)
|
if (w is BoxedBasicValue) {
|
||||||
when {
|
onMergeSuccess(v, w)
|
||||||
v is TaintedBoxedValue -> v
|
when {
|
||||||
w is TaintedBoxedValue -> w
|
v is TaintedBoxedValue -> v
|
||||||
v.type != w.type -> mergeBoxedHazardous(v, w, isLocalVariable)
|
w is TaintedBoxedValue -> w
|
||||||
else -> v // two clean boxed values with the same type are equal
|
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 ->
|
w is BoxedBasicValue ->
|
||||||
mergeBoxedHazardous(w, v, isLocalVariable)
|
mergeBoxedHazardous(w, v, isLocalVariable)
|
||||||
else ->
|
else ->
|
||||||
|
|||||||
+7
-3
@@ -30,10 +30,14 @@ abstract class ReferenceTrackingInterpreter : OptimizationBasicInterpreter() {
|
|||||||
else
|
else
|
||||||
createTaintedValue(v, w)
|
createTaintedValue(v, w)
|
||||||
|
|
||||||
v is TrackedReferenceValue && w is TrackedReferenceValue ->
|
v is TrackedReferenceValue -> {
|
||||||
createPossiblyMergedValue(v, w)
|
if (w is TrackedReferenceValue)
|
||||||
|
createPossiblyMergedValue(v, w)
|
||||||
|
else
|
||||||
|
createTaintedValue(v, w)
|
||||||
|
}
|
||||||
|
|
||||||
v is TrackedReferenceValue || w is TrackedReferenceValue ->
|
w is TrackedReferenceValue ->
|
||||||
createTaintedValue(v, w)
|
createTaintedValue(v, w)
|
||||||
|
|
||||||
else ->
|
else ->
|
||||||
|
|||||||
+15
-14
@@ -96,20 +96,21 @@ class NullabilityInterpreter(private val generationState: GenerationState) : Opt
|
|||||||
|
|
||||||
override fun merge(v: BasicValue, w: BasicValue): BasicValue =
|
override fun merge(v: BasicValue, w: BasicValue): BasicValue =
|
||||||
when {
|
when {
|
||||||
v is NullBasicValue && w is NullBasicValue ->
|
v === NullBasicValue -> if (w === NullBasicValue) NullBasicValue else StrictBasicValue.REFERENCE_VALUE
|
||||||
NullBasicValue
|
|
||||||
v is NullBasicValue || w is NullBasicValue ->
|
w === NullBasicValue -> StrictBasicValue.REFERENCE_VALUE
|
||||||
StrictBasicValue.REFERENCE_VALUE
|
|
||||||
v is ProgressionIteratorBasicValue && w is ProgressionIteratorBasicValue ->
|
v is ProgressionIteratorBasicValue -> when (w) {
|
||||||
mergeNotNullValuesOfSameKind(v, w)
|
is ProgressionIteratorBasicValue -> mergeNotNullValuesOfSameKind(v, w)
|
||||||
v is ProgressionIteratorBasicValue && w is NotNullBasicValue ->
|
is NotNullBasicValue -> NotNullBasicValue.NOT_NULL_REFERENCE_VALUE
|
||||||
NotNullBasicValue.NOT_NULL_REFERENCE_VALUE
|
else -> super.merge(v, w)
|
||||||
w is ProgressionIteratorBasicValue && v is NotNullBasicValue ->
|
}
|
||||||
NotNullBasicValue.NOT_NULL_REFERENCE_VALUE
|
v is NotNullBasicValue -> when (w) {
|
||||||
v is NotNullBasicValue && w is NotNullBasicValue ->
|
is ProgressionIteratorBasicValue -> NotNullBasicValue.NOT_NULL_REFERENCE_VALUE
|
||||||
mergeNotNullValuesOfSameKind(v, w)
|
is NotNullBasicValue -> mergeNotNullValuesOfSameKind(v, w)
|
||||||
else ->
|
else -> super.merge(v, w)
|
||||||
super.merge(v, w)
|
}
|
||||||
|
else -> super.merge(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun mergeNotNullValuesOfSameKind(v: StrictBasicValue, w: StrictBasicValue) =
|
private fun mergeNotNullValuesOfSameKind(v: StrictBasicValue, w: StrictBasicValue) =
|
||||||
|
|||||||
Reference in New Issue
Block a user