Index: runtime/vm/assembler_ia32.cc |
diff --git a/runtime/vm/assembler_ia32.cc b/runtime/vm/assembler_ia32.cc |
index 713365db6367d1067a1442869329a423cb0f3bee..ad379a21437f4aa62af268ba8b665d15516a578b 100644 |
--- a/runtime/vm/assembler_ia32.cc |
+++ b/runtime/vm/assembler_ia32.cc |
@@ -2903,26 +2903,33 @@ void Assembler::SmiUntagOrCheckClass(Register object, |
void Assembler::LoadClassIdMayBeSmi(Register result, Register object) { |
- ASSERT(result != object); |
- static const intptr_t kSmiCidSource = kSmiCid << RawObject::kClassIdTagPos; |
+ Label smi, join; |
- // Make a dummy "Object" whose cid is kSmiCid. |
- movl(result, Immediate(reinterpret_cast<int32_t>(&kSmiCidSource) + 1)); |
- |
- // Check if object (in tmp) is a Smi. |
testl(object, Immediate(kSmiTagMask)); |
+ j(EQUAL, &smi, Assembler::kNearJump); |
+ LoadClassId(result, object); |
+ jmp(&join, Assembler::kNearJump); |
+ |
+ Bind(&smi); |
+ movl(result, Immediate(kSmiCid)); |
- // If the object is not a Smi, use the original object to load the cid. |
- // Otherwise, the dummy object is used, and the result is kSmiCid. |
- cmovne(result, object); |
- LoadClassId(result, result); |
+ Bind(&join); |
} |
void Assembler::LoadTaggedClassIdMayBeSmi(Register result, Register object) { |
- LoadClassIdMayBeSmi(result, object); |
- // Tag the result. |
+ Label smi, join; |
+ |
+ testl(object, Immediate(kSmiTagMask)); |
+ j(EQUAL, &smi, Assembler::kNearJump); |
+ LoadClassId(result, object); |
SmiTag(result); |
+ jmp(&join, Assembler::kNearJump); |
+ |
+ Bind(&smi); |
+ movl(result, Immediate(Smi::RawValue(kSmiCid))); |
+ |
+ Bind(&join); |
} |