Fix iCache misses for GetKind on x86,x86_64
GetKind() takes about 2.6% of total compilation time on x86_64.
The primary reason is that the target call GetKindInternal() is often
beyond the page boundary causing frequent i-cache misses.
This patch removes the virtual call to GetKindInternal () and instead
keeps the InstructionKind into each constructed instruction.
Since we have about 121 instructions in total as of now,
it takes about 7 extra bits in each instruction.
dex2oat runs about 12% faster with --compiler-filter=everything on an
APK of 25MB.
Test: Tested the patch by running host art tests.
Rebased.
Change-Id: Ia7bbcd67180151e4565507164a718acbb6284885
Signed-off-by: Gupta Kumar, Sanjiv <sanjiv.kumar.gupta@intel.com>
diff --git a/compiler/optimizing/nodes_shared.h b/compiler/optimizing/nodes_shared.h
index e837f1e..29358e1 100644
--- a/compiler/optimizing/nodes_shared.h
+++ b/compiler/optimizing/nodes_shared.h
@@ -32,7 +32,8 @@
HInstruction* mul_left,
HInstruction* mul_right,
uint32_t dex_pc = kNoDexPc)
- : HExpression(type, SideEffects::None(), dex_pc), op_kind_(op) {
+ : HExpression(kMultiplyAccumulate, type, SideEffects::None(), dex_pc),
+ op_kind_(op) {
SetRawInputAt(kInputAccumulatorIndex, accumulator);
SetRawInputAt(kInputMulLeftIndex, mul_left);
SetRawInputAt(kInputMulRightIndex, mul_right);
@@ -68,7 +69,12 @@
HInstruction* left,
HInstruction* right,
uint32_t dex_pc = kNoDexPc)
- : HBinaryOperation(result_type, left, right, SideEffects::None(), dex_pc),
+ : HBinaryOperation(kBitwiseNegatedRight,
+ result_type,
+ left,
+ right,
+ SideEffects::None(),
+ dex_pc),
op_kind_(op) {
DCHECK(op == HInstruction::kAnd || op == HInstruction::kOr || op == HInstruction::kXor) << op;
}
@@ -143,7 +149,10 @@
public:
HIntermediateAddressIndex(
HInstruction* index, HInstruction* offset, HInstruction* shift, uint32_t dex_pc)
- : HExpression(DataType::Type::kInt32, SideEffects::None(), dex_pc) {
+ : HExpression(kIntermediateAddressIndex,
+ DataType::Type::kInt32,
+ SideEffects::None(),
+ dex_pc) {
SetRawInputAt(0, index);
SetRawInputAt(1, offset);
SetRawInputAt(2, shift);
@@ -193,7 +202,7 @@
// is an extension.
int shift = 0,
uint32_t dex_pc = kNoDexPc)
- : HExpression(instr->GetType(), SideEffects::None(), dex_pc),
+ : HExpression(kDataProcWithShifterOp, instr->GetType(), SideEffects::None(), dex_pc),
instr_kind_(instr->GetKind()), op_kind_(op),
shift_amount_(shift & (instr->GetType() == DataType::Type::kInt32
? kMaxIntShiftDistance