 Chromium Code Reviews
 Chromium Code Reviews Issue 1410953003:
  [Interpreter] Adds delete operator to interpreter.  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 1410953003:
  [Interpreter] Adds delete operator to interpreter.  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| OLD | NEW | 
|---|---|
| 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/v8.h" | 5 #include "src/v8.h" | 
| 6 | 6 | 
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" | 
| 8 #include "src/interpreter/bytecode-array-iterator.h" | 8 #include "src/interpreter/bytecode-array-iterator.h" | 
| 9 #include "src/interpreter/bytecode-generator.h" | 9 #include "src/interpreter/bytecode-generator.h" | 
| 10 #include "src/interpreter/interpreter.h" | 10 #include "src/interpreter/interpreter.h" | 
| (...skipping 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1827 1, | 1827 1, | 
| 1828 8, | 1828 8, | 
| 1829 { | 1829 { | 
| 1830 B(LdaSmi8), U8(13), // | 1830 B(LdaSmi8), U8(13), // | 
| 1831 B(Star), R(0), // TODO(oth): Ldar R(X) following Star R(X) | 1831 B(Star), R(0), // TODO(oth): Ldar R(X) following Star R(X) | 
| 1832 B(Ldar), R(0), // could be culled in bytecode array builder. | 1832 B(Ldar), R(0), // could be culled in bytecode array builder. | 
| 1833 B(TypeOf), // | 1833 B(TypeOf), // | 
| 1834 B(Return), // | 1834 B(Return), // | 
| 1835 }, | 1835 }, | 
| 1836 0}, | 1836 0}, | 
| 1837 }; | 1837 {"var x = 13;" | 
| 1838 "return ~x;", | |
| 1839 1 * kPointerSize, | |
| 1840 1, | |
| 1841 9, | |
| 1842 { | |
| 1843 B(LdaSmi8), U8(13), // | |
| 1844 B(Star), R(0), // | |
| 1845 B(LdaSmi8), U8(-1), // | |
| 1846 B(BitwiseXor), R(0), // | |
| 1847 B(Return), // | |
| 1848 }, | |
| 1849 0}, | |
| 1850 {"var x = 13;" | |
| 1851 "return +x;", | |
| 1852 1 * kPointerSize, | |
| 1853 1, | |
| 1854 9, | |
| 1855 { | |
| 1856 B(LdaSmi8), U8(13), // | |
| 1857 B(Star), R(0), // | |
| 1858 B(LdaSmi8), U8(1), // | |
| 1859 B(Mul), R(0), // | |
| 1860 B(Return), // | |
| 1861 }, | |
| 1862 0}, | |
| 1863 {"var x = 13;" | |
| 1864 "return -x;", | |
| 1865 1 * kPointerSize, | |
| 1866 1, | |
| 1867 9, | |
| 1868 { | |
| 1869 B(LdaSmi8), U8(13), // | |
| 1870 B(Star), R(0), // | |
| 1871 B(LdaSmi8), U8(-1), // | |
| 1872 B(Mul), R(0), // | |
| 1873 B(Return), // | |
| 1874 }, | |
| 1875 0}}; | |
| 1838 | 1876 | 
| 1839 for (size_t i = 0; i < arraysize(snippets); i++) { | 1877 for (size_t i = 0; i < arraysize(snippets); i++) { | 
| 1840 Handle<BytecodeArray> bytecode_array = | 1878 Handle<BytecodeArray> bytecode_array = | 
| 1879 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | |
| 1880 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | |
| 1881 } | |
| 1882 } | |
| 1883 | |
| 1884 | |
| 1885 TEST(Delete) { | |
| 
rmcilroy
2015/10/26 14:31:07
Could you also make have a TEST(GlobalDelete) with
 
mythria
2015/10/27 10:50:48
Done.
 | |
| 1886 InitializedHandleScope handle_scope; | |
| 1887 BytecodeGeneratorHelper helper; | |
| 1888 | |
| 1889 int deep_elements_flags = | |
| 1890 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; | |
| 1891 int closure = Register::function_closure().index(); | |
| 1892 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | |
| 1893 | |
| 1894 ExpectedSnippet<InstanceType> snippets[] = { | |
| 1895 {"var a = {x:13, y:14}; return delete a.x;", | |
| 1896 1 * kPointerSize, | |
| 1897 1, | |
| 1898 12, | |
| 1899 { | |
| 1900 B(LdaConstant), U8(0), // | |
| 1901 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | |
| 1902 B(Star), R(0), // | |
| 1903 B(LdaConstant), U8(1), // | |
| 1904 B(DeletePropertySloppy), R(0), // | |
| 1905 B(Return) | |
| 1906 }, | |
| 1907 2, | |
| 1908 {InstanceType::FIXED_ARRAY_TYPE, | |
| 1909 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | |
| 1910 {"'use strict'; var a = {x:13, y:14}; return delete a.x;", | |
| 1911 1 * kPointerSize, | |
| 1912 1, | |
| 1913 12, | |
| 1914 { | |
| 1915 B(LdaConstant), U8(0), // | |
| 1916 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | |
| 1917 B(Star), R(0), // | |
| 1918 B(LdaConstant), U8(1), // | |
| 1919 B(DeletePropertyStrict), R(0), // | |
| 1920 B(Return) | |
| 1921 }, | |
| 1922 2, | |
| 1923 {InstanceType::FIXED_ARRAY_TYPE, | |
| 1924 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | |
| 1925 {"var a = {1:13, 2:14}; return delete a[2];", | |
| 1926 1 * kPointerSize, | |
| 1927 1, | |
| 1928 12, | |
| 1929 { | |
| 1930 B(LdaConstant), U8(0), // | |
| 1931 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | |
| 1932 B(Star), R(0), // | |
| 1933 B(LdaSmi8), U8(2), // | |
| 1934 B(DeletePropertySloppy), R(0), // | |
| 1935 B(Return) | |
| 1936 }, | |
| 1937 1, | |
| 1938 {InstanceType::FIXED_ARRAY_TYPE} | |
| 1939 }, | |
| 1940 {"var a = 10; return delete a;", | |
| 1941 1 * kPointerSize, | |
| 1942 1, | |
| 1943 6, | |
| 1944 { | |
| 1945 B(LdaSmi8), U8(10), // | |
| 1946 B(Star), R(0), // | |
| 1947 B(LdaFalse), // | |
| 1948 B(Return) | |
| 1949 }, | |
| 1950 0 | |
| 1951 }, | |
| 1952 {"'use strict';" | |
| 1953 "var a = {1:10};" | |
| 1954 "(function f1() {return a;});" | |
| 1955 "return delete a[1];", | |
| 1956 2 * kPointerSize, | |
| 1957 1, | |
| 1958 29, | |
| 1959 { | |
| 1960 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | |
| 1961 R(closure), U8(1), // | |
| 1962 B(PushContext), R(0), // | |
| 1963 B(LdaConstant), U8(0), // | |
| 1964 B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), // | |
| 1965 B(StaContextSlot), R(0), U8(first_context_slot), // | |
| 1966 B(LdaConstant), U8(1), // | |
| 1967 B(CreateClosure), U8(0), // | |
| 1968 B(LdaContextSlot), R(0), U8(first_context_slot), // | |
| 1969 B(Star), R(1), // | |
| 1970 B(LdaSmi8), U8(1), // | |
| 1971 B(DeletePropertyStrict), R(1), // | |
| 1972 B(Return) | |
| 1973 }, | |
| 1974 2, | |
| 1975 {InstanceType::FIXED_ARRAY_TYPE, | |
| 1976 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | |
| 1977 }; | |
| 
rmcilroy
2015/10/26 14:31:07
nit - could you also test your unresolvable refere
 
mythria
2015/10/27 10:50:48
Done.
 | |
| 1978 | |
| 1979 for (size_t i = 0; i < arraysize(snippets); i++) { | |
| 1980 Handle<BytecodeArray> bytecode_array = | |
| 1841 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 1981 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 
| 1842 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1982 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 
| 1843 } | 1983 } | 
| 1844 } | 1984 } | 
| 1845 | 1985 | 
| 1846 | 1986 | 
| 1847 TEST(FunctionLiterals) { | 1987 TEST(FunctionLiterals) { | 
| 1848 InitializedHandleScope handle_scope; | 1988 InitializedHandleScope handle_scope; | 
| 1849 BytecodeGeneratorHelper helper; | 1989 BytecodeGeneratorHelper helper; | 
| 1850 | 1990 | 
| (...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3489 for (size_t i = 0; i < arraysize(snippets); i++) { | 3629 for (size_t i = 0; i < arraysize(snippets); i++) { | 
| 3490 Handle<BytecodeArray> bytecode_array = | 3630 Handle<BytecodeArray> bytecode_array = | 
| 3491 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 3631 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 
| 3492 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 3632 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 
| 3493 } | 3633 } | 
| 3494 } | 3634 } | 
| 3495 | 3635 | 
| 3496 } // namespace interpreter | 3636 } // namespace interpreter | 
| 3497 } // namespace internal | 3637 } // namespace internal | 
| 3498 } // namespace v8 | 3638 } // namespace v8 | 
| OLD | NEW |