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

Side by Side Diff: test/cctest/test-assembler-arm.cc

Issue 887073007: [arm] Assembler support for internal references. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use different bit pattern Created 5 years, 10 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
« no previous file with comments | « src/arm/constants-arm.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 assm.GetCode(&desc); 1878 assm.GetCode(&desc);
1879 Handle<Code> code = isolate->factory()->NewCode( 1879 Handle<Code> code = isolate->factory()->NewCode(
1880 desc, Code::ComputeFlags(Code::STUB), code_object); 1880 desc, Code::ComputeFlags(Code::STUB), code_object);
1881 F1 f = FUNCTION_CAST<F1>(code->entry()); 1881 F1 f = FUNCTION_CAST<F1>(code->entry());
1882 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 21, 0, 0, 0, 0)); 1882 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 21, 0, 0, 0, 0));
1883 ::printf("f() = %d\n", res); 1883 ::printf("f() = %d\n", res);
1884 CHECK_EQ(42, res); 1884 CHECK_EQ(42, res);
1885 } 1885 }
1886 1886
1887 1887
1888 TEST(jump_tables1) {
1889 // Test jump tables with forward jumps.
1890 CcTest::InitializeVM();
1891 Isolate* isolate = CcTest::i_isolate();
1892 HandleScope scope(isolate);
1893 Assembler assm(isolate, nullptr, 0);
1894
1895 const int kNumCases = 512;
1896 int values[kNumCases];
1897 isolate->random_number_generator()->NextBytes(values, sizeof(values));
1898 Label labels[kNumCases];
1899
1900 __ stm(db_w, sp, lr.bit());
1901
1902 Label done;
1903 __ BlockConstPoolFor(kNumCases + 2);
1904 {
1905 PredictableCodeSizeScope predictable(
1906 &assm, (kNumCases + 2) * Assembler::kInstrSize);
1907 __ ldr(pc, MemOperand(pc, r0, LSL, 2));
1908 __ nop();
1909 for (int i = 0; i < kNumCases; ++i) {
1910 __ dd(&labels[i]);
1911 }
1912 }
1913
1914 for (int i = 0; i < kNumCases; ++i) {
1915 __ bind(&labels[i]);
1916 __ mov(r0, Operand(values[i]));
1917 __ b(&done);
1918 }
1919
1920 __ bind(&done);
1921 __ ldm(ia_w, sp, pc.bit());
1922
1923 CodeDesc desc;
1924 assm.GetCode(&desc);
1925 Handle<Code> code = isolate->factory()->NewCode(
1926 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1927 #ifdef OBJECT_PRINT
1928 code->Print(std::cout);
1929 #endif
1930 F1 f = FUNCTION_CAST<F1>(code->entry());
1931 for (int i = 0; i < kNumCases; ++i) {
1932 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, i, 0, 0, 0, 0));
1933 ::printf("f(%d) = %d\n", i, res);
1934 CHECK_EQ(values[i], res);
1935 }
1936 }
1937
1938
1939 TEST(jump_tables2) {
1940 // Test jump tables with backward jumps.
1941 CcTest::InitializeVM();
1942 Isolate* isolate = CcTest::i_isolate();
1943 HandleScope scope(isolate);
1944 Assembler assm(isolate, nullptr, 0);
1945
1946 const int kNumCases = 512;
1947 int values[kNumCases];
1948 isolate->random_number_generator()->NextBytes(values, sizeof(values));
1949 Label labels[kNumCases];
1950
1951 __ stm(db_w, sp, lr.bit());
1952
1953 Label done, dispatch;
1954 __ b(&dispatch);
1955
1956 for (int i = 0; i < kNumCases; ++i) {
1957 __ bind(&labels[i]);
1958 __ mov(r0, Operand(values[i]));
1959 __ b(&done);
1960 }
1961
1962 __ bind(&dispatch);
1963 __ BlockConstPoolFor(kNumCases + 2);
1964 {
1965 PredictableCodeSizeScope predictable(
1966 &assm, (kNumCases + 2) * Assembler::kInstrSize);
1967 __ ldr(pc, MemOperand(pc, r0, LSL, 2));
1968 __ nop();
1969 for (int i = 0; i < kNumCases; ++i) {
1970 __ dd(&labels[i]);
1971 }
1972 }
1973
1974 __ bind(&done);
1975 __ ldm(ia_w, sp, pc.bit());
1976
1977 CodeDesc desc;
1978 assm.GetCode(&desc);
1979 Handle<Code> code = isolate->factory()->NewCode(
1980 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1981 #ifdef OBJECT_PRINT
1982 code->Print(std::cout);
1983 #endif
1984 F1 f = FUNCTION_CAST<F1>(code->entry());
1985 for (int i = 0; i < kNumCases; ++i) {
1986 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, i, 0, 0, 0, 0));
1987 ::printf("f(%d) = %d\n", i, res);
1988 CHECK_EQ(values[i], res);
1989 }
1990 }
1991
1992
1993 TEST(jump_tables3) {
1994 // Test jump tables with backward jumps and embedded heap objects.
1995 CcTest::InitializeVM();
1996 Isolate* isolate = CcTest::i_isolate();
1997 HandleScope scope(isolate);
1998 Assembler assm(isolate, nullptr, 0);
1999
2000 const int kNumCases = 256;
2001 Handle<Object> values[kNumCases];
2002 for (int i = 0; i < kNumCases; ++i) {
2003 double value = isolate->random_number_generator()->NextDouble();
2004 values[i] = isolate->factory()->NewHeapNumber(value, IMMUTABLE, TENURED);
2005 }
2006 Label labels[kNumCases];
2007
2008 __ stm(db_w, sp, lr.bit());
2009
2010 Label done, dispatch;
2011 __ b(&dispatch);
2012
2013 for (int i = 0; i < kNumCases; ++i) {
2014 __ bind(&labels[i]);
2015 __ mov(r0, Operand(values[i]));
2016 __ b(&done);
2017 }
2018
2019 __ bind(&dispatch);
2020 __ BlockConstPoolFor(kNumCases + 2);
2021 {
2022 PredictableCodeSizeScope predictable(
2023 &assm, (kNumCases + 2) * Assembler::kInstrSize);
2024 __ ldr(pc, MemOperand(pc, r0, LSL, 2));
2025 __ nop();
2026 for (int i = 0; i < kNumCases; ++i) {
2027 __ dd(&labels[i]);
2028 }
2029 }
2030
2031 __ bind(&done);
2032 __ ldm(ia_w, sp, pc.bit());
2033
2034 CodeDesc desc;
2035 assm.GetCode(&desc);
2036 Handle<Code> code = isolate->factory()->NewCode(
2037 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
2038 #ifdef OBJECT_PRINT
2039 code->Print(std::cout);
2040 #endif
2041 F1 f = FUNCTION_CAST<F1>(code->entry());
2042 for (int i = 0; i < kNumCases; ++i) {
2043 Handle<Object> result(CALL_GENERATED_CODE(f, i, 0, 0, 0, 0), isolate);
2044 #ifdef OBJECT_PRINT
2045 ::printf("f(%d) = ", i);
2046 result->Print(std::cout);
2047 ::printf("\n");
2048 #endif
2049 CHECK(values[i].is_identical_to(result));
2050 }
2051 }
2052
2053
1888 TEST(ARMv8_vrintX) { 2054 TEST(ARMv8_vrintX) {
1889 // Test the vrintX floating point instructions. 2055 // Test the vrintX floating point instructions.
1890 CcTest::InitializeVM(); 2056 CcTest::InitializeVM();
1891 Isolate* isolate = CcTest::i_isolate(); 2057 Isolate* isolate = CcTest::i_isolate();
1892 HandleScope scope(isolate); 2058 HandleScope scope(isolate);
1893 2059
1894 typedef struct { 2060 typedef struct {
1895 double input; 2061 double input;
1896 double ar; 2062 double ar;
1897 double nr; 2063 double nr;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 CHECK_VRINT(inf, inf, inf, inf, inf, inf) 2140 CHECK_VRINT(inf, inf, inf, inf, inf, inf)
1975 CHECK_VRINT(-inf, -inf, -inf, -inf, -inf, -inf) 2141 CHECK_VRINT(-inf, -inf, -inf, -inf, -inf, -inf)
1976 CHECK_VRINT(-0.0, -0.0, -0.0, -0.0, -0.0, -0.0) 2142 CHECK_VRINT(-0.0, -0.0, -0.0, -0.0, -0.0, -0.0)
1977 double nan = std::numeric_limits<double>::quiet_NaN(); 2143 double nan = std::numeric_limits<double>::quiet_NaN();
1978 CHECK_VRINT(nan, nan, nan, nan, nan, nan) 2144 CHECK_VRINT(nan, nan, nan, nan, nan, nan)
1979 2145
1980 #undef CHECK_VRINT 2146 #undef CHECK_VRINT
1981 } 2147 }
1982 } 2148 }
1983 #undef __ 2149 #undef __
OLDNEW
« no previous file with comments | « src/arm/constants-arm.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698