Get rid of kInstrUnconditional.
Replace its use with an inline function dexIsGoto(flags), which uses
the existing flag bits kInstrCanBranch and kInstrCanContinue.
Change-Id: I84f533f619434ad0ad2831c147b50f6dc79b9928
diff --git a/libdex/InstrUtils.c b/libdex/InstrUtils.c
index e98de91..01c8311 100644
--- a/libdex/InstrUtils.c
+++ b/libdex/InstrUtils.c
@@ -586,7 +586,7 @@
case OP_GOTO:
case OP_GOTO_16:
case OP_GOTO_32:
- flags = kInstrCanBranch | kInstrUnconditional;
+ flags = kInstrCanBranch;
break;
/* conditional branches */
diff --git a/libdex/InstrUtils.h b/libdex/InstrUtils.h
index 4c4dcfe..e65a1bf 100644
--- a/libdex/InstrUtils.h
+++ b/libdex/InstrUtils.h
@@ -124,7 +124,6 @@
kInstrCanThrow = 1 << 3, // could cause an exception to be thrown
kInstrCanReturn = 1 << 4, // returns, no additional statements
kInstrInvoke = 1 << 5, // a flavor of invoke
- kInstrUnconditional = 1 << 6, // unconditional branch
};
/*
@@ -177,6 +176,14 @@
}
/*
+ * Returns true if the given flags represent a goto (unconditional branch).
+ */
+DEX_INLINE bool dexIsGoto(int flags)
+{
+ return (flags & (kInstrCanBranch | kInstrCanContinue)) == kInstrCanBranch;
+}
+
+/*
* Allocate and populate a 256-element array with instruction formats.
*/
InstructionFormat* dexCreateInstrFormatTable(void);
diff --git a/vm/compiler/Frontend.c b/vm/compiler/Frontend.c
index 7d28b36..3c1e837 100644
--- a/vm/compiler/Frontend.c
+++ b/vm/compiler/Frontend.c
@@ -820,7 +820,7 @@
/* For unconditional branches, request a hot chaining cell */
} else {
#if !defined(WITH_SELF_VERIFICATION)
- newBB = dvmCompilerNewBB(flags & kInstrUnconditional ?
+ newBB = dvmCompilerNewBB(dexIsGoto(flags) ?
kChainingCellHot :
kChainingCellNormal);
newBB->startOffset = targetOffset;
@@ -830,7 +830,7 @@
targetOffset <= curBB->lastMIRInsn->offset) {
newBB = dvmCompilerNewBB(kChainingCellBackwardBranch);
} else {
- newBB = dvmCompilerNewBB(flags & kInstrUnconditional ?
+ newBB = dvmCompilerNewBB(dexIsGoto(flags) ?
kChainingCellHot :
kChainingCellNormal);
}
diff --git a/vm/interp/Jit.c b/vm/interp/Jit.c
index 1abf68b..be9d6df 100644
--- a/vm/interp/Jit.c
+++ b/vm/interp/Jit.c
@@ -784,7 +784,7 @@
interpState->jitState = kJitTSelectEnd;
}
- if ( ((flags & kInstrUnconditional) == 0) &&
+ if (!dexIsGoto(flags) &&
/* don't end trace on INVOKE_DIRECT_EMPTY */
(decInsn.opCode != OP_INVOKE_DIRECT_EMPTY) &&
((flags & (kInstrCanBranch |