Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1584)

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 6682026: Fix SmiCompare on 64 bit to distinguish between comparisons where... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 void MacroAssembler::SmiToInteger64(Register dst, const Operand& src) { 830 void MacroAssembler::SmiToInteger64(Register dst, const Operand& src) {
831 movsxlq(dst, Operand(src, kSmiShift / kBitsPerByte)); 831 movsxlq(dst, Operand(src, kSmiShift / kBitsPerByte));
832 } 832 }
833 833
834 834
835 void MacroAssembler::SmiTest(Register src) { 835 void MacroAssembler::SmiTest(Register src) {
836 testq(src, src); 836 testq(src, src);
837 } 837 }
838 838
839 839
840 void MacroAssembler::SmiCompare(Register dst, Register src) {
841 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.
842 }
843
844
845 void MacroAssembler::SmiCompare(Register dst, Smi* src) { 840 void MacroAssembler::SmiCompare(Register dst, Smi* src) {
841 if (FLAG_debug_code) {
842 AbortIfNotSmi(dst);
843 }
844 // Actually, knowing the register is a smi doesn't enable any optimizations
845 // with the current tagging scheme.
846 SmiCompareWithObject(dst, src);
847 }
848
849
850 void MacroAssembler::SmiCompareWithObject(Register dst, Smi* src) {
846 ASSERT(!dst.is(kScratchRegister)); 851 ASSERT(!dst.is(kScratchRegister));
847 if (src->value() == 0) { 852 if (src->value() == 0) {
848 testq(dst, dst); 853 testq(dst, dst);
849 } else { 854 } else {
850 Register constant_reg = GetSmiConstant(src); 855 Register constant_reg = GetSmiConstant(src);
851 cmpq(dst, constant_reg); 856 cmpq(dst, constant_reg);
852 } 857 }
853 } 858 }
854 859
855 860
856 void MacroAssembler::SmiCompare(Register dst, const Operand& src) { 861 void MacroAssembler::SmiCompare(Register dst, const Operand& src) {
862 if (FLAG_debug_code) {
863 AbortIfNotSmi(dst);
864 AbortIfNotSmi(src);
865 }
Lasse Reichstein 2011/03/14 08:51:01 Adding asserts: Good!
Erik Corry 2011/03/14 16:26:45 Done.
857 cmpq(dst, src); 866 cmpq(dst, src);
858 } 867 }
859 868
860 869
861 void MacroAssembler::SmiCompare(const Operand& dst, Register src) { 870 void MacroAssembler::SmiCompare(const Operand& dst, Register src) {
871 if (FLAG_debug_code) {
872 AbortIfNotSmi(dst);
873 AbortIfNotSmi(src);
874 }
862 cmpq(dst, src); 875 cmpq(dst, src);
863 } 876 }
864 877
865 878
866 void MacroAssembler::SmiCompare(const Operand& dst, Smi* src) { 879 void MacroAssembler::SmiCompare(const Operand& dst, Smi* src) {
880 if (FLAG_debug_code) {
881 AbortIfNotSmi(dst);
882 }
867 cmpl(Operand(dst, kSmiShift / kBitsPerByte), Immediate(src->value())); 883 cmpl(Operand(dst, kSmiShift / kBitsPerByte), Immediate(src->value()));
868 } 884 }
869 885
870 886
887 void MacroAssembler::SmiCompareWithObject(const Operand& dst, Smi* src) {
888 // The Operand cannot use the scratch register, since we use the scratch
889 // register to get around the lack of 64 bit immediates in the instruction
890 // set.
891 ASSERT(!dst.AddressUsesRegister(kScratchRegister));
892 movq(kScratchRegister, src);
893 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.
894 }
895
896
871 void MacroAssembler::SmiCompareInteger32(const Operand& dst, Register src) { 897 void MacroAssembler::SmiCompareInteger32(const Operand& dst, Register src) {
872 cmpl(Operand(dst, kSmiShift / kBitsPerByte), src); 898 cmpl(Operand(dst, kSmiShift / kBitsPerByte), src);
873 } 899 }
874 900
875 901
876 void MacroAssembler::PositiveSmiTimesPowerOfTwoToInteger64(Register dst, 902 void MacroAssembler::PositiveSmiTimesPowerOfTwoToInteger64(Register dst,
877 Register src, 903 Register src,
878 int power) { 904 int power) {
879 ASSERT(power >= 0); 905 ASSERT(power >= 0);
880 ASSERT(power < 64); 906 ASSERT(power < 64);
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 Move(dst, Smi::cast(*source)); 1371 Move(dst, Smi::cast(*source));
1346 } else { 1372 } else {
1347 movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT); 1373 movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT);
1348 movq(dst, kScratchRegister); 1374 movq(dst, kScratchRegister);
1349 } 1375 }
1350 } 1376 }
1351 1377
1352 1378
1353 void MacroAssembler::Cmp(Register dst, Handle<Object> source) { 1379 void MacroAssembler::Cmp(Register dst, Handle<Object> source) {
1354 if (source->IsSmi()) { 1380 if (source->IsSmi()) {
1355 SmiCompare(dst, Smi::cast(*source)); 1381 SmiCompareWithObject(dst, Smi::cast(*source));
1356 } else { 1382 } else {
1357 Move(kScratchRegister, source); 1383 Move(kScratchRegister, source);
1358 cmpq(dst, kScratchRegister); 1384 cmpq(dst, kScratchRegister);
1359 } 1385 }
1360 } 1386 }
1361 1387
1362 1388
1363 void MacroAssembler::Cmp(const Operand& dst, Handle<Object> source) { 1389 void MacroAssembler::Cmp(const Operand& dst, Handle<Object> source) {
1364 if (source->IsSmi()) { 1390 if (source->IsSmi()) {
1365 SmiCompare(dst, Smi::cast(*source)); 1391 SmiCompareWithObject(dst, Smi::cast(*source));
1366 } else { 1392 } else {
1367 ASSERT(source->IsHeapObject()); 1393 ASSERT(source->IsHeapObject());
1368 movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT); 1394 movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT);
1369 cmpq(dst, kScratchRegister); 1395 cmpq(dst, kScratchRegister);
1370 } 1396 }
1371 } 1397 }
1372 1398
1373 1399
1374 void MacroAssembler::Push(Handle<Object> source) { 1400 void MacroAssembler::Push(Handle<Object> source) {
1375 if (source->IsSmi()) { 1401 if (source->IsSmi()) {
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 } 1778 }
1753 1779
1754 1780
1755 void MacroAssembler::AbortIfNotSmi(Register object) { 1781 void MacroAssembler::AbortIfNotSmi(Register object) {
1756 NearLabel ok; 1782 NearLabel ok;
1757 Condition is_smi = CheckSmi(object); 1783 Condition is_smi = CheckSmi(object);
1758 Assert(is_smi, "Operand is not a smi"); 1784 Assert(is_smi, "Operand is not a smi");
1759 } 1785 }
1760 1786
1761 1787
1788 void MacroAssembler::AbortIfNotSmi(const Operand& object) {
1789 Condition is_smi = CheckSmi(object);
1790 Assert(is_smi, "Operand is not a smi");
1791 }
1792
1793
1762 void MacroAssembler::AbortIfNotString(Register object) { 1794 void MacroAssembler::AbortIfNotString(Register object) {
1763 testb(object, Immediate(kSmiTagMask)); 1795 testb(object, Immediate(kSmiTagMask));
1764 Assert(not_equal, "Operand is not a string"); 1796 Assert(not_equal, "Operand is not a string");
1765 push(object); 1797 push(object);
1766 movq(object, FieldOperand(object, HeapObject::kMapOffset)); 1798 movq(object, FieldOperand(object, HeapObject::kMapOffset));
1767 CmpInstanceType(object, FIRST_NONSTRING_TYPE); 1799 CmpInstanceType(object, FIRST_NONSTRING_TYPE);
1768 pop(object); 1800 pop(object);
1769 Assert(below, "Operand is not a string"); 1801 Assert(below, "Operand is not a string");
1770 } 1802 }
1771 1803
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
2686 CPU::FlushICache(address_, size_); 2718 CPU::FlushICache(address_, size_);
2687 2719
2688 // Check that the code was patched as expected. 2720 // Check that the code was patched as expected.
2689 ASSERT(masm_.pc_ == address_ + size_); 2721 ASSERT(masm_.pc_ == address_ + size_);
2690 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 2722 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
2691 } 2723 }
2692 2724
2693 } } // namespace v8::internal 2725 } } // namespace v8::internal
2694 2726
2695 #endif // V8_TARGET_ARCH_X64 2727 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698