Index: src/arm/ic-arm.cc |
diff --git a/src/arm/ic-arm.cc b/src/arm/ic-arm.cc |
index e84365789be42805a1d3e91eb76c6b93f3298f81..8973e6d7f014f0210b4eb9e826b21b3ff0d19e56 100644 |
--- a/src/arm/ic-arm.cc |
+++ b/src/arm/ic-arm.cc |
@@ -1690,12 +1690,12 @@ void CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { |
// Activate inlined smi code. |
if (previous_state == UNINITIALIZED) { |
- PatchInlinedSmiCode(address()); |
+ PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK); |
} |
} |
-void PatchInlinedSmiCode(Address address) { |
+void PatchInlinedSmiCode(Address address, InlinedSmiCheck check) { |
Address cmp_instruction_address = |
address + Assembler::kCallTargetAddressOffset; |
@@ -1729,34 +1729,31 @@ void PatchInlinedSmiCode(Address address) { |
Instr instr_at_patch = Assembler::instr_at(patch_address); |
Instr branch_instr = |
Assembler::instr_at(patch_address + Instruction::kInstrSize); |
- ASSERT(Assembler::IsCmpRegister(instr_at_patch)); |
- ASSERT_EQ(Assembler::GetRn(instr_at_patch).code(), |
- Assembler::GetRm(instr_at_patch).code()); |
+ // This is patching a conditional "jump if not smi/jump if smi" site. |
+ // Enabling by changing from |
+ // cmp rx, rx |
+ // b eq/ne, <target> |
+ // to |
+ // tst rx, #kSmiTagMask |
+ // b ne/eq, <target> |
+ // and vice-versa to be disabled again. |
+ CodePatcher patcher(patch_address, 2); |
+ Register reg = Assembler::GetRn(instr_at_patch); |
+ if (check == ENABLE_INLINED_SMI_CHECK) { |
+ ASSERT(Assembler::IsCmpRegister(instr_at_patch)); |
+ ASSERT_EQ(Assembler::GetRn(instr_at_patch).code(), |
+ Assembler::GetRm(instr_at_patch).code()); |
+ patcher.masm()->tst(reg, Operand(kSmiTagMask)); |
+ } else { |
+ ASSERT(check == DISABLE_INLINED_SMI_CHECK); |
+ ASSERT(Assembler::IsTstImmediate(instr_at_patch)); |
+ patcher.masm()->cmp(reg, reg); |
+ } |
ASSERT(Assembler::IsBranch(branch_instr)); |
if (Assembler::GetCondition(branch_instr) == eq) { |
- // This is patching a "jump if not smi" site to be active. |
- // Changing |
- // cmp rx, rx |
- // b eq, <target> |
- // to |
- // tst rx, #kSmiTagMask |
- // b ne, <target> |
- CodePatcher patcher(patch_address, 2); |
- Register reg = Assembler::GetRn(instr_at_patch); |
- patcher.masm()->tst(reg, Operand(kSmiTagMask)); |
patcher.EmitCondition(ne); |
} else { |
ASSERT(Assembler::GetCondition(branch_instr) == ne); |
- // This is patching a "jump if smi" site to be active. |
- // Changing |
- // cmp rx, rx |
- // b ne, <target> |
- // to |
- // tst rx, #kSmiTagMask |
- // b eq, <target> |
- CodePatcher patcher(patch_address, 2); |
- Register reg = Assembler::GetRn(instr_at_patch); |
- patcher.masm()->tst(reg, Operand(kSmiTagMask)); |
patcher.EmitCondition(eq); |
} |
} |