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

Side by Side Diff: test/cctest/test-code-stub-assembler.cc

Issue 2461363002: [stubs]: Support 1->2 byte copies in CopyStringCharacters (Closed)
Patch Set: Review feedback Created 4 years, 1 month 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/zone/zone.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/utils/random-number-generator.h" 5 #include "src/base/utils/random-number-generator.h"
6 #include "src/code-factory.h" 6 #include "src/code-factory.h"
7 #include "src/code-stub-assembler.h" 7 #include "src/code-stub-assembler.h"
8 #include "src/compiler/node.h" 8 #include "src/compiler/node.h"
9 #include "src/ic/stub-cache.h" 9 #include "src/ic/stub-cache.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 ft.Call(isolate->factory()->undefined_value(), 1780 ft.Call(isolate->factory()->undefined_value(),
1781 Handle<Smi>(Smi::FromInt(1234), isolate), 1781 Handle<Smi>(Smi::FromInt(1234), isolate),
1782 isolate->factory()->undefined_value(), 1782 isolate->factory()->undefined_value(),
1783 Handle<Smi>(Smi::FromInt(kNumProgramaticParams * kPointerSize), 1783 Handle<Smi>(Smi::FromInt(kNumProgramaticParams * kPointerSize),
1784 isolate)) 1784 isolate))
1785 .ToHandleChecked(); 1785 .ToHandleChecked();
1786 CHECK_EQ(1234, Handle<Smi>::cast(result)->value()); 1786 CHECK_EQ(1234, Handle<Smi>::cast(result)->value());
1787 } 1787 }
1788 } 1788 }
1789 1789
1790 TEST(OneToTwoByteStringCopy) {
1791 Isolate* isolate(CcTest::InitIsolateOnce());
1792
1793 CodeStubAssemblerTester m(isolate, 2);
1794
1795 m.CopyStringCharacters(
1796 m.Parameter(0), m.Parameter(1), m.SmiConstant(Smi::FromInt(0)),
1797 m.SmiConstant(Smi::FromInt(0)), m.SmiConstant(Smi::FromInt(5)),
1798 String::ONE_BYTE_ENCODING, String::TWO_BYTE_ENCODING,
1799 CodeStubAssembler::SMI_PARAMETERS);
1800 m.Return(m.SmiConstant(Smi::FromInt(0)));
1801
1802 Handle<Code> code = m.GenerateCode();
1803 CHECK(!code.is_null());
1804
1805 Handle<String> string1 = isolate->factory()->InternalizeUtf8String("abcde");
1806 uc16 array[] = {1000, 1001, 1002, 1003, 1004};
1807 Vector<const uc16> str(array);
1808 Handle<String> string2 =
1809 isolate->factory()->NewStringFromTwoByte(str).ToHandleChecked();
1810 FunctionTester ft(code, 2);
1811 ft.Call(string1, string2);
1812 CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[0],
1813 Handle<SeqTwoByteString>::cast(string2)->GetChars()[0]);
1814 CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[1],
1815 Handle<SeqTwoByteString>::cast(string2)->GetChars()[1]);
1816 CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[2],
1817 Handle<SeqTwoByteString>::cast(string2)->GetChars()[2]);
1818 CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[3],
1819 Handle<SeqTwoByteString>::cast(string2)->GetChars()[3]);
1820 CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[4],
1821 Handle<SeqTwoByteString>::cast(string2)->GetChars()[4]);
1822 }
1823
1824 TEST(OneToOneByteStringCopy) {
1825 Isolate* isolate(CcTest::InitIsolateOnce());
1826
1827 CodeStubAssemblerTester m(isolate, 2);
1828
1829 m.CopyStringCharacters(
1830 m.Parameter(0), m.Parameter(1), m.SmiConstant(Smi::FromInt(0)),
1831 m.SmiConstant(Smi::FromInt(0)), m.SmiConstant(Smi::FromInt(5)),
1832 String::ONE_BYTE_ENCODING, String::ONE_BYTE_ENCODING,
1833 CodeStubAssembler::SMI_PARAMETERS);
1834 m.Return(m.SmiConstant(Smi::FromInt(0)));
1835
1836 Handle<Code> code = m.GenerateCode();
1837 CHECK(!code.is_null());
1838
1839 Handle<String> string1 = isolate->factory()->InternalizeUtf8String("abcde");
1840 uint8_t array[] = {100, 101, 102, 103, 104};
1841 Vector<const uint8_t> str(array);
1842 Handle<String> string2 =
1843 isolate->factory()->NewStringFromOneByte(str).ToHandleChecked();
1844 FunctionTester ft(code, 2);
1845 ft.Call(string1, string2);
1846 CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[0],
1847 Handle<SeqOneByteString>::cast(string2)->GetChars()[0]);
1848 CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[1],
1849 Handle<SeqOneByteString>::cast(string2)->GetChars()[1]);
1850 CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[2],
1851 Handle<SeqOneByteString>::cast(string2)->GetChars()[2]);
1852 CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[3],
1853 Handle<SeqOneByteString>::cast(string2)->GetChars()[3]);
1854 CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[4],
1855 Handle<SeqOneByteString>::cast(string2)->GetChars()[4]);
1856 }
1857
1858 TEST(OneToOneByteStringCopyNonZeroStart) {
1859 Isolate* isolate(CcTest::InitIsolateOnce());
1860
1861 CodeStubAssemblerTester m(isolate, 2);
1862
1863 m.CopyStringCharacters(
1864 m.Parameter(0), m.Parameter(1), m.SmiConstant(Smi::FromInt(0)),
1865 m.SmiConstant(Smi::FromInt(3)), m.SmiConstant(Smi::FromInt(2)),
1866 String::ONE_BYTE_ENCODING, String::ONE_BYTE_ENCODING,
1867 CodeStubAssembler::SMI_PARAMETERS);
1868 m.Return(m.SmiConstant(Smi::FromInt(0)));
1869
1870 Handle<Code> code = m.GenerateCode();
1871 CHECK(!code.is_null());
1872
1873 Handle<String> string1 = isolate->factory()->InternalizeUtf8String("abcde");
1874 uint8_t array[] = {100, 101, 102, 103, 104};
1875 Vector<const uint8_t> str(array);
1876 Handle<String> string2 =
1877 isolate->factory()->NewStringFromOneByte(str).ToHandleChecked();
1878 FunctionTester ft(code, 2);
1879 ft.Call(string1, string2);
1880 CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[0],
1881 Handle<SeqOneByteString>::cast(string2)->GetChars()[3]);
1882 CHECK_EQ(Handle<SeqOneByteString>::cast(string1)->GetChars()[1],
1883 Handle<SeqOneByteString>::cast(string2)->GetChars()[4]);
1884 CHECK_EQ(100, Handle<SeqOneByteString>::cast(string2)->GetChars()[0]);
1885 CHECK_EQ(101, Handle<SeqOneByteString>::cast(string2)->GetChars()[1]);
1886 CHECK_EQ(102, Handle<SeqOneByteString>::cast(string2)->GetChars()[2]);
1887 }
1888
1889 TEST(TwoToTwoByteStringCopy) {
1890 Isolate* isolate(CcTest::InitIsolateOnce());
1891
1892 CodeStubAssemblerTester m(isolate, 2);
1893
1894 m.CopyStringCharacters(
1895 m.Parameter(0), m.Parameter(1), m.SmiConstant(Smi::FromInt(0)),
1896 m.SmiConstant(Smi::FromInt(0)), m.SmiConstant(Smi::FromInt(5)),
1897 String::TWO_BYTE_ENCODING, String::TWO_BYTE_ENCODING,
1898 CodeStubAssembler::SMI_PARAMETERS);
1899 m.Return(m.SmiConstant(Smi::FromInt(0)));
1900
1901 Handle<Code> code = m.GenerateCode();
1902 CHECK(!code.is_null());
1903
1904 uc16 array1[] = {2000, 2001, 2002, 2003, 2004};
1905 Vector<const uc16> str1(array1);
1906 Handle<String> string1 =
1907 isolate->factory()->NewStringFromTwoByte(str1).ToHandleChecked();
1908 uc16 array2[] = {1000, 1001, 1002, 1003, 1004};
1909 Vector<const uc16> str2(array2);
1910 Handle<String> string2 =
1911 isolate->factory()->NewStringFromTwoByte(str2).ToHandleChecked();
1912 FunctionTester ft(code, 2);
1913 ft.Call(string1, string2);
1914 CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars()[0],
1915 Handle<SeqTwoByteString>::cast(string2)->GetChars()[0]);
1916 CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars()[1],
1917 Handle<SeqTwoByteString>::cast(string2)->GetChars()[1]);
1918 CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars()[2],
1919 Handle<SeqTwoByteString>::cast(string2)->GetChars()[2]);
1920 CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars()[3],
1921 Handle<SeqTwoByteString>::cast(string2)->GetChars()[3]);
1922 CHECK_EQ(Handle<SeqTwoByteString>::cast(string1)->GetChars()[4],
1923 Handle<SeqTwoByteString>::cast(string2)->GetChars()[4]);
1924 }
1925
1790 } // namespace internal 1926 } // namespace internal
1791 } // namespace v8 1927 } // namespace v8
OLDNEW
« no previous file with comments | « src/zone/zone.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698