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

Side by Side Diff: test/cctest/test-macro-assembler-x64.cc

Issue 21014003: Optionally use 31-bits SMI value for 64-bit system (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Introduce SmiFunctionInvoker to abstract the difference between FullCodeGen and LCodeGen Created 7 years, 4 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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), exit); 879 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), exit);
880 __ cmpq(r9, r8); 880 __ cmpq(r9, r8);
881 __ j(not_equal, exit); 881 __ j(not_equal, exit);
882 882
883 __ incq(rax); // Test 5. 883 __ incq(rax); // Test 5.
884 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), exit); 884 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), exit);
885 __ cmpq(rcx, r8); 885 __ cmpq(rcx, r8);
886 __ j(not_equal, exit); 886 __ j(not_equal, exit);
887 } 887 }
888 888
889
889 static void SmiSubOverflowTest(MacroAssembler* masm, 890 static void SmiSubOverflowTest(MacroAssembler* masm,
890 Label* exit, 891 Label* exit,
891 int id, 892 int id,
892 int x) { 893 int x) {
893 // Subtracts a Smi from x so that the subtraction overflows. 894 // Subtracts a Smi from x so that the subtraction overflows.
894 ASSERT(x != -1); // Can't overflow by subtracting a Smi. 895 ASSERT(x != -1); // Can't overflow by subtracting a Smi.
895 int y_max = (x < 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue + 0); 896 int y_max = (x < 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue + 0);
896 int y_min = (x < 0) ? (Smi::kMaxValue + x + 2) : (Smi::kMinValue + x); 897 int y_min = (x < 0) ? (Smi::kMaxValue + x + 2) : (Smi::kMinValue + x);
897 898
898 __ movl(rax, Immediate(id)); 899 __ movl(rax, Immediate(id));
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 __ ret(0); 1035 __ ret(0);
1035 1036
1036 CodeDesc desc; 1037 CodeDesc desc;
1037 masm->GetCode(&desc); 1038 masm->GetCode(&desc);
1038 // Call the function from C++. 1039 // Call the function from C++.
1039 int result = FUNCTION_CAST<F0>(buffer)(); 1040 int result = FUNCTION_CAST<F0>(buffer)();
1040 CHECK_EQ(0, result); 1041 CHECK_EQ(0, result);
1041 } 1042 }
1042 1043
1043 1044
1044
1045 void TestSmiMul(MacroAssembler* masm, Label* exit, int id, int x, int y) { 1045 void TestSmiMul(MacroAssembler* masm, Label* exit, int id, int x, int y) {
1046 int64_t result = static_cast<int64_t>(x) * static_cast<int64_t>(y); 1046 int64_t result = static_cast<int64_t>(x) * static_cast<int64_t>(y);
1047 bool negative_zero = (result == 0) && (x < 0 || y < 0); 1047 bool negative_zero = (result == 0) && (x < 0 || y < 0);
1048 __ Move(rcx, Smi::FromInt(x)); 1048 __ Move(rcx, Smi::FromInt(x));
1049 __ movq(r11, rcx); 1049 __ movq(r11, rcx);
1050 __ Move(rdx, Smi::FromInt(y)); 1050 __ Move(rdx, Smi::FromInt(y));
1051 if (Smi::IsValid(result) && !negative_zero) { 1051 if (Smi::IsValid(result) && !negative_zero) {
1052 __ movl(rax, Immediate(id)); 1052 __ movl(rax, Immediate(id));
1053 __ Move(r8, Smi::FromIntptr(result)); 1053 __ Move(r8, Smi::FromIntptr(result));
1054 __ SmiMul(r9, rcx, rdx, exit); 1054 __ SmiMul(r9, rcx, rdx, exit);
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 // Call the function from C++. 1820 // Call the function from C++.
1821 int result = FUNCTION_CAST<F0>(buffer)(); 1821 int result = FUNCTION_CAST<F0>(buffer)();
1822 CHECK_EQ(0, result); 1822 CHECK_EQ(0, result);
1823 } 1823 }
1824 1824
1825 1825
1826 void TestSmiShiftLeft(MacroAssembler* masm, Label* exit, int id, int x) { 1826 void TestSmiShiftLeft(MacroAssembler* masm, Label* exit, int id, int x) {
1827 const int shifts[] = { 0, 1, 7, 24, kSmiValueSize - 1}; 1827 const int shifts[] = { 0, 1, 7, 24, kSmiValueSize - 1};
1828 const int kNumShifts = 5; 1828 const int kNumShifts = 5;
1829 __ movl(rax, Immediate(id)); 1829 __ movl(rax, Immediate(id));
1830 MacroAssembler::SmiFunctionInvoker invoker(exit);
1830 for (int i = 0; i < kNumShifts; i++) { 1831 for (int i = 0; i < kNumShifts; i++) {
1831 // rax == id + i * 10. 1832 // rax == id + i * 10.
1832 int shift = shifts[i]; 1833 int shift = shifts[i];
1833 int result = x << shift; 1834 int result = x << shift;
1834 CHECK(Smi::IsValid(result)); 1835 if (Smi::IsValid(result)) {
1835 __ Move(r8, Smi::FromInt(result)); 1836 __ Move(r8, Smi::FromInt(result));
1836 __ Move(rcx, Smi::FromInt(x)); 1837 __ Move(rcx, Smi::FromInt(x));
1837 __ SmiShiftLeftConstant(r9, rcx, shift); 1838 __ SmiShiftLeftConstant(r9, rcx, shift, invoker);
1838 1839
1839 __ incq(rax); 1840 __ incq(rax);
1840 __ cmpq(r9, r8); 1841 __ cmpq(r9, r8);
1841 __ j(not_equal, exit); 1842 __ j(not_equal, exit);
1842 1843
1843 __ incq(rax); 1844 __ incq(rax);
1844 __ Move(rcx, Smi::FromInt(x)); 1845 __ Move(rcx, Smi::FromInt(x));
1845 __ SmiShiftLeftConstant(rcx, rcx, shift); 1846 if (kSmiValueSize == 32) {
1847 __ SmiShiftLeftConstant(rcx, rcx, shift, invoker);
1848 } else {
1849 ASSERT(kSmiValueSize == 31);
1850 __ SmiShiftLeftConstant(r9, rcx, shift, invoker);
1851 __ movq(rcx, r9);
1852 }
1846 1853
1847 __ incq(rax); 1854 __ incq(rax);
1848 __ cmpq(rcx, r8); 1855 __ cmpq(rcx, r8);
1849 __ j(not_equal, exit); 1856 __ j(not_equal, exit);
1850 1857
1851 __ incq(rax); 1858 __ incq(rax);
1852 __ Move(rdx, Smi::FromInt(x)); 1859 __ Move(rdx, Smi::FromInt(x));
1853 __ Move(rcx, Smi::FromInt(shift)); 1860 __ Move(rcx, Smi::FromInt(shift));
1854 __ SmiShiftLeft(r9, rdx, rcx); 1861 __ SmiShiftLeft(r9, rdx, rcx, exit);
1855 1862
1856 __ incq(rax); 1863 __ incq(rax);
1857 __ cmpq(r9, r8); 1864 __ cmpq(r9, r8);
1858 __ j(not_equal, exit); 1865 __ j(not_equal, exit);
1859 1866
1860 __ incq(rax); 1867 __ incq(rax);
1861 __ Move(rdx, Smi::FromInt(x)); 1868 __ Move(rdx, Smi::FromInt(x));
1862 __ Move(r11, Smi::FromInt(shift)); 1869 __ Move(r11, Smi::FromInt(shift));
1863 __ SmiShiftLeft(r9, rdx, r11); 1870 __ SmiShiftLeft(r9, rdx, r11, exit);
1864 1871
1865 __ incq(rax); 1872 __ incq(rax);
1866 __ cmpq(r9, r8); 1873 __ cmpq(r9, r8);
1867 __ j(not_equal, exit); 1874 __ j(not_equal, exit);
1868 1875
1869 __ incq(rax); 1876 __ incq(rax);
1870 __ Move(rdx, Smi::FromInt(x)); 1877 __ Move(rdx, Smi::FromInt(x));
1871 __ Move(r11, Smi::FromInt(shift)); 1878 __ Move(r11, Smi::FromInt(shift));
1872 __ SmiShiftLeft(rdx, rdx, r11); 1879 if (kSmiValueSize == 32) {
1880 __ SmiShiftLeft(rdx, rdx, r11, exit);
1881 } else {
1882 __ SmiShiftLeft(r9, rdx, r11, exit);
1883 __ movq(rdx, r9);
1884 }
1885 __ incq(rax);
1886 __ cmpq(rdx, r8);
1887 __ j(not_equal, exit);
1873 1888
1874 __ incq(rax); 1889 __ incq(rax);
1875 __ cmpq(rdx, r8); 1890 } else {
1876 __ j(not_equal, exit); 1891 __ Move(rdx, Smi::FromInt(x));
1892 __ Move(rcx, Smi::FromInt(shift));
1893 __ movq(r11, rcx);
1894 Label fail_ok1;
1895 __ SmiShiftLeft(r9, rdx, rcx, &fail_ok1);
1896 __ jmp(exit);
1897 __ bind(&fail_ok1);
1877 1898
1878 __ incq(rax); 1899 __ incq(rax);
1900 __ cmpq(rcx, r11);
1901 __ j(not_equal, exit);
1902
1903 __ incq(rax);
1904 __ Move(rcx, Smi::FromInt(x));
1905 __ Move(rdx, Smi::FromInt(shift));
1906 __ movq(r11, rcx);
1907 Label fail_ok2;
1908 __ SmiShiftLeft(r9, rcx, rdx, &fail_ok2);
1909 __ jmp(exit);
1910 __ bind(&fail_ok2);
1911
1912 __ incq(rax);
1913 __ cmpq(rcx, r11);
1914 __ j(not_equal, exit);
1915
1916 __ addq(rax, Immediate(7));
1917 }
1879 } 1918 }
1880 } 1919 }
1881 1920
1882 1921
1883 TEST(SmiShiftLeft) { 1922 TEST(SmiShiftLeft) {
1884 v8::internal::V8::Initialize(NULL); 1923 v8::internal::V8::Initialize(NULL);
1885 // Allocate an executable page of memory. 1924 // Allocate an executable page of memory.
1886 size_t actual_size; 1925 size_t actual_size;
1887 byte* buffer = 1926 byte* buffer =
1888 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, 1927 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4,
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 CodeDesc desc; 2554 CodeDesc desc;
2516 masm->GetCode(&desc); 2555 masm->GetCode(&desc);
2517 // Call the function from C++. 2556 // Call the function from C++.
2518 int result = FUNCTION_CAST<F0>(buffer)(); 2557 int result = FUNCTION_CAST<F0>(buffer)();
2519 CHECK_EQ(0, result); 2558 CHECK_EQ(0, result);
2520 } 2559 }
2521 2560
2522 2561
2523 2562
2524 #undef __ 2563 #undef __
OLDNEW
« src/x64/macro-assembler-x64.h ('K') | « test/cctest/test-log-stack-tracer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698