Chromium Code Reviews| Index: src/x64/macro-assembler-x64.cc |
| =================================================================== |
| --- src/x64/macro-assembler-x64.cc (revision 7153) |
| +++ src/x64/macro-assembler-x64.cc (working copy) |
| @@ -837,12 +837,17 @@ |
| } |
| -void MacroAssembler::SmiCompare(Register dst, Register src) { |
| - cmpq(dst, src); |
|
Lasse Reichstein
2011/03/14 08:51:01
Don't remove the SmiCompare function. Do use it wh
Erik Corry
2011/03/14 16:26:45
Done.
|
| +void MacroAssembler::SmiCompare(Register dst, Smi* src) { |
| + if (FLAG_debug_code) { |
| + AbortIfNotSmi(dst); |
| + } |
| + // Actually, knowing the register is a smi doesn't enable any optimizations |
| + // with the current tagging scheme. |
| + SmiCompareWithObject(dst, src); |
| } |
| -void MacroAssembler::SmiCompare(Register dst, Smi* src) { |
| +void MacroAssembler::SmiCompareWithObject(Register dst, Smi* src) { |
| ASSERT(!dst.is(kScratchRegister)); |
| if (src->value() == 0) { |
| testq(dst, dst); |
| @@ -854,20 +859,41 @@ |
| void MacroAssembler::SmiCompare(Register dst, const Operand& src) { |
| + if (FLAG_debug_code) { |
| + AbortIfNotSmi(dst); |
| + AbortIfNotSmi(src); |
| + } |
|
Lasse Reichstein
2011/03/14 08:51:01
Adding asserts: Good!
Erik Corry
2011/03/14 16:26:45
Done.
|
| cmpq(dst, src); |
| } |
| void MacroAssembler::SmiCompare(const Operand& dst, Register src) { |
| + if (FLAG_debug_code) { |
| + AbortIfNotSmi(dst); |
| + AbortIfNotSmi(src); |
| + } |
| cmpq(dst, src); |
| } |
| void MacroAssembler::SmiCompare(const Operand& dst, Smi* src) { |
| + if (FLAG_debug_code) { |
| + AbortIfNotSmi(dst); |
| + } |
| cmpl(Operand(dst, kSmiShift / kBitsPerByte), Immediate(src->value())); |
| } |
| +void MacroAssembler::SmiCompareWithObject(const Operand& dst, Smi* src) { |
| + // The Operand cannot use the scratch register, since we use the scratch |
| + // register to get around the lack of 64 bit immediates in the instruction |
| + // set. |
| + ASSERT(!dst.AddressUsesRegister(kScratchRegister)); |
| + movq(kScratchRegister, src); |
| + cmpq(dst, kScratchRegister); |
|
Lasse Reichstein
2011/03/14 08:51:01
This is wasteful, since it doesn't use the kSmiCon
Erik Corry
2011/03/14 16:26:45
Done.
|
| +} |
| + |
| + |
| void MacroAssembler::SmiCompareInteger32(const Operand& dst, Register src) { |
| cmpl(Operand(dst, kSmiShift / kBitsPerByte), src); |
| } |
| @@ -1352,7 +1378,7 @@ |
| void MacroAssembler::Cmp(Register dst, Handle<Object> source) { |
| if (source->IsSmi()) { |
| - SmiCompare(dst, Smi::cast(*source)); |
| + SmiCompareWithObject(dst, Smi::cast(*source)); |
| } else { |
| Move(kScratchRegister, source); |
| cmpq(dst, kScratchRegister); |
| @@ -1362,7 +1388,7 @@ |
| void MacroAssembler::Cmp(const Operand& dst, Handle<Object> source) { |
| if (source->IsSmi()) { |
| - SmiCompare(dst, Smi::cast(*source)); |
| + SmiCompareWithObject(dst, Smi::cast(*source)); |
| } else { |
| ASSERT(source->IsHeapObject()); |
| movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT); |
| @@ -1759,6 +1785,12 @@ |
| } |
| +void MacroAssembler::AbortIfNotSmi(const Operand& object) { |
| + Condition is_smi = CheckSmi(object); |
| + Assert(is_smi, "Operand is not a smi"); |
| +} |
| + |
| + |
| void MacroAssembler::AbortIfNotString(Register object) { |
| testb(object, Immediate(kSmiTagMask)); |
| Assert(not_equal, "Operand is not a string"); |