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

Side by Side Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 1400753003: [Interpreter] Add array literal support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_literal
Patch Set: Rebase Created 5 years, 2 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/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | 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/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 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 1937 {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
1938 }; 1938 };
1939 1939
1940 for (size_t i = 0; i < arraysize(snippets); i++) { 1940 for (size_t i = 0; i < arraysize(snippets); i++) {
1941 Handle<BytecodeArray> bytecode_array = 1941 Handle<BytecodeArray> bytecode_array =
1942 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 1942 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
1943 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 1943 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1944 } 1944 }
1945 } 1945 }
1946 1946
1947
1948 TEST(ArrayLiterals) {
1949 InitializedHandleScope handle_scope;
1950 BytecodeGeneratorHelper helper;
1951
1952 int simple_flags =
1953 ArrayLiteral::kDisableMementos | ArrayLiteral::kShallowElements;
1954 int deep_elements_flags = ArrayLiteral::kDisableMementos;
1955 ExpectedSnippet<InstanceType> snippets[] = {
1956 {"return [ 1, 2 ];",
1957 0,
1958 1,
1959 6,
1960 {
1961 B(LdaConstant), U8(0), //
1962 B(CreateArrayLiteral), U8(0), U8(simple_flags), //
1963 B(Return) //
1964 },
1965 1,
1966 {InstanceType::FIXED_ARRAY_TYPE}},
1967 {"var a = 1; return [ a, a + 1 ];",
1968 4 * kPointerSize,
1969 1,
1970 37,
1971 {
1972 B(LdaSmi8), U8(1), //
1973 B(Star), R(0), //
1974 B(LdaConstant), U8(0), //
1975 B(CreateArrayLiteral), U8(0), U8(3), //
1976 B(Star), R(2), //
1977 B(LdaZero), //
1978 B(Star), R(1), //
1979 B(Ldar), R(0), //
1980 B(KeyedStoreICGeneric), R(2), R(1), //
1981 B(LdaSmi8), U8(1), //
1982 B(Star), R(1), //
1983 B(Ldar), R(0), //
1984 B(Star), R(3), //
1985 B(LdaSmi8), U8(1), //
1986 B(Add), R(3), //
1987 B(KeyedStoreICGeneric), R(2), R(1), //
1988 B(Ldar), R(2), //
1989 B(Return) //
1990 },
1991 1,
1992 {InstanceType::FIXED_ARRAY_TYPE}},
1993 {"return [ [ 1, 2 ], [ 3 ] ];",
1994 0,
1995 1,
1996 6,
1997 {
1998 B(LdaConstant), U8(0), //
1999 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), //
2000 B(Return) //
2001 },
2002 1,
2003 {InstanceType::FIXED_ARRAY_TYPE}},
2004 {"var a = 1; return [ [ a, 2 ], [ a + 2 ] ];",
2005 6 * kPointerSize,
2006 1,
2007 67,
2008 {
2009 B(LdaSmi8), U8(1), //
2010 B(Star), R(0), //
2011 B(LdaConstant), U8(0), //
2012 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), //
2013 B(Star), R(2), //
2014 B(LdaZero), //
2015 B(Star), R(1), //
2016 B(LdaConstant), U8(1), //
2017 B(CreateArrayLiteral), U8(0), U8(simple_flags), //
2018 B(Star), R(4), //
2019 B(LdaZero), //
2020 B(Star), R(3), //
2021 B(Ldar), R(0), //
2022 B(KeyedStoreICGeneric), R(4), R(3), //
2023 B(Ldar), R(4), //
2024 B(KeyedStoreICGeneric), R(2), R(1), //
2025 B(LdaSmi8), U8(1), //
2026 B(Star), R(1), //
2027 B(LdaConstant), U8(2), //
2028 B(CreateArrayLiteral), U8(1), U8(simple_flags), //
2029 B(Star), R(4), //
2030 B(LdaZero), //
2031 B(Star), R(3), //
2032 B(Ldar), R(0), //
2033 B(Star), R(5), //
2034 B(LdaSmi8), U8(2), //
2035 B(Add), R(5), //
2036 B(KeyedStoreICGeneric), R(4), R(3), //
2037 B(Ldar), R(4), //
2038 B(KeyedStoreICGeneric), R(2), R(1), //
2039 B(Ldar), R(2), //
2040 B(Return), //
2041 },
2042 3,
2043 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE,
2044 InstanceType::FIXED_ARRAY_TYPE}},
2045 };
2046
2047 for (size_t i = 0; i < arraysize(snippets); i++) {
2048 Handle<BytecodeArray> bytecode_array =
2049 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
2050 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2051 }
2052 }
2053
1947 } // namespace interpreter 2054 } // namespace interpreter
1948 } // namespace internal 2055 } // namespace internal
1949 } // namespace v8 2056 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698