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

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: 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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 for (int i = 0; i < kNumShifts; i++) { 1830 for (int i = 0; i < kNumShifts; i++) {
1831 // rax == id + i * 10. 1831 // rax == id + i * 10.
1832 int shift = shifts[i]; 1832 int shift = shifts[i];
1833 int result = x << shift; 1833 int result = x << shift;
1834 #if !V8_USE_31_BITS_SMI_VALUE
1834 CHECK(Smi::IsValid(result)); 1835 CHECK(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);
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);
(...skipping 25 matching lines...) Expand all
1869 __ incq(rax); 1870 __ incq(rax);
1870 __ Move(rdx, Smi::FromInt(x)); 1871 __ Move(rdx, Smi::FromInt(x));
1871 __ Move(r11, Smi::FromInt(shift)); 1872 __ Move(r11, Smi::FromInt(shift));
1872 __ SmiShiftLeft(rdx, rdx, r11); 1873 __ SmiShiftLeft(rdx, rdx, r11);
1873 1874
1874 __ incq(rax); 1875 __ incq(rax);
1875 __ cmpq(rdx, r8); 1876 __ cmpq(rdx, r8);
1876 __ j(not_equal, exit); 1877 __ j(not_equal, exit);
1877 1878
1878 __ incq(rax); 1879 __ incq(rax);
1880 #else
1881 if (Smi::IsValid(result)) {
1882 __ Move(r8, Smi::FromInt(result));
1883 __ Move(rcx, Smi::FromInt(x));
1884 __ SmiShiftLeftConstant(r9, rcx, shift, exit);
1885
1886 __ incq(rax);
1887 __ cmpq(r9, r8);
1888 __ j(not_equal, exit);
1889
1890 __ incq(rax);
1891 __ Move(rcx, Smi::FromInt(x));
1892 __ SmiShiftLeftConstant(rcx, rcx, shift, exit);
1893
1894 __ incq(rax);
1895 __ cmpq(rcx, r8);
1896 __ j(not_equal, exit);
1897
1898 __ incq(rax);
1899 __ Move(rdx, Smi::FromInt(x));
1900 __ Move(rcx, Smi::FromInt(shift));
1901 __ SmiShiftLeft(r9, rdx, rcx, exit);
1902
1903 __ incq(rax);
1904 __ cmpq(r9, r8);
1905 __ j(not_equal, exit);
1906
1907 __ incq(rax);
1908 __ Move(rdx, Smi::FromInt(x));
1909 __ Move(r11, Smi::FromInt(shift));
1910 __ SmiShiftLeft(r9, rdx, r11, exit);
1911
1912 __ incq(rax);
1913 __ cmpq(r9, r8);
1914 __ j(not_equal, exit);
1915
1916 __ incq(rax);
1917 __ Move(rdx, Smi::FromInt(x));
1918 __ Move(r11, Smi::FromInt(shift));
1919 __ SmiShiftLeft(rdx, rdx, r11, exit);
1920
1921 __ incq(rax);
1922 __ cmpq(rdx, r8);
1923 __ j(not_equal, exit);
1924
1925 __ incq(rax);
1926 } else {
1927 __ Move(rdx, Smi::FromInt(x));
1928 __ Move(rcx, Smi::FromInt(shift));
1929 __ movq(r11, rcx);
1930 Label fail_ok1;
1931 __ SmiShiftLeft(r9, rdx, rcx, &fail_ok1);
1932 __ jmp(exit);
1933 __ bind(&fail_ok1);
1934
1935 __ incq(rax);
1936 __ cmpq(rcx, r11);
1937 __ j(not_equal, exit);
1938
1939 __ incq(rax);
1940 __ Move(rcx, Smi::FromInt(x));
1941 __ Move(rdx, Smi::FromInt(shift));
1942 __ movq(r11, rcx);
1943 Label fail_ok2;
1944 __ SmiShiftLeft(r9, rcx, rdx, &fail_ok2);
1945 __ jmp(exit);
1946 __ bind(&fail_ok2);
1947
1948 __ incq(rax);
1949 __ cmpq(rcx, r11);
1950 __ j(not_equal, exit);
1951
1952 __ addq(rax, Immediate(7));
1953 }
1954 #endif
1879 } 1955 }
1880 } 1956 }
1881 1957
1882 1958
1883 TEST(SmiShiftLeft) { 1959 TEST(SmiShiftLeft) {
1884 v8::internal::V8::Initialize(NULL); 1960 v8::internal::V8::Initialize(NULL);
1885 // Allocate an executable page of memory. 1961 // Allocate an executable page of memory.
1886 size_t actual_size; 1962 size_t actual_size;
1887 byte* buffer = 1963 byte* buffer =
1888 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, 1964 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4,
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 CodeDesc desc; 2591 CodeDesc desc;
2516 masm->GetCode(&desc); 2592 masm->GetCode(&desc);
2517 // Call the function from C++. 2593 // Call the function from C++.
2518 int result = FUNCTION_CAST<F0>(buffer)(); 2594 int result = FUNCTION_CAST<F0>(buffer)();
2519 CHECK_EQ(0, result); 2595 CHECK_EQ(0, result);
2520 } 2596 }
2521 2597
2522 2598
2523 2599
2524 #undef __ 2600 #undef __
OLDNEW
« src/x64/lithium-codegen-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