| 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 1933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1944 Handle<BytecodeArray> bytecode_array = | 1944 Handle<BytecodeArray> bytecode_array = |
| 1945 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 1945 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 1946 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1946 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 1947 } | 1947 } |
| 1948 } | 1948 } |
| 1949 | 1949 |
| 1950 | 1950 |
| 1951 TEST(ArrayLiterals) { | 1951 TEST(ArrayLiterals) { |
| 1952 InitializedHandleScope handle_scope; | 1952 InitializedHandleScope handle_scope; |
| 1953 BytecodeGeneratorHelper helper; | 1953 BytecodeGeneratorHelper helper; |
| 1954 Zone zone; |
| 1955 |
| 1956 FeedbackVectorSpec feedback_spec(&zone); |
| 1957 FeedbackVectorSlot slot1 = feedback_spec.AddKeyedStoreICSlot(); |
| 1958 FeedbackVectorSlot slot2 = feedback_spec.AddKeyedStoreICSlot(); |
| 1959 FeedbackVectorSlot slot3 = feedback_spec.AddKeyedStoreICSlot(); |
| 1960 |
| 1961 Handle<i::TypeFeedbackVector> vector = |
| 1962 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 1954 | 1963 |
| 1955 int simple_flags = | 1964 int simple_flags = |
| 1956 ArrayLiteral::kDisableMementos | ArrayLiteral::kShallowElements; | 1965 ArrayLiteral::kDisableMementos | ArrayLiteral::kShallowElements; |
| 1957 int deep_elements_flags = ArrayLiteral::kDisableMementos; | 1966 int deep_elements_flags = ArrayLiteral::kDisableMementos; |
| 1958 ExpectedSnippet<InstanceType> snippets[] = { | 1967 ExpectedSnippet<InstanceType> snippets[] = { |
| 1959 {"return [ 1, 2 ];", | 1968 {"return [ 1, 2 ];", |
| 1960 0, | 1969 0, |
| 1961 1, | 1970 1, |
| 1962 6, | 1971 6, |
| 1963 { | 1972 { |
| 1964 B(LdaConstant), U8(0), // | 1973 B(LdaConstant), U8(0), // |
| 1965 B(CreateArrayLiteral), U8(0), U8(simple_flags), // | 1974 B(CreateArrayLiteral), U8(0), U8(simple_flags), // |
| 1966 B(Return) // | 1975 B(Return) // |
| 1967 }, | 1976 }, |
| 1968 1, | 1977 1, |
| 1969 {InstanceType::FIXED_ARRAY_TYPE}}, | 1978 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 1970 {"var a = 1; return [ a, a + 1 ];", | 1979 {"var a = 1; return [ a, a + 1 ];", |
| 1971 4 * kPointerSize, | 1980 4 * kPointerSize, |
| 1972 1, | 1981 1, |
| 1973 37, | 1982 39, |
| 1974 { | 1983 { |
| 1975 B(LdaSmi8), U8(1), // | 1984 B(LdaSmi8), U8(1), // |
| 1976 B(Star), R(0), // | 1985 B(Star), R(0), // |
| 1977 B(LdaConstant), U8(0), // | 1986 B(LdaConstant), U8(0), // |
| 1978 B(CreateArrayLiteral), U8(0), U8(3), // | 1987 B(CreateArrayLiteral), U8(0), U8(3), // |
| 1979 B(Star), R(2), // | 1988 B(Star), R(2), // |
| 1980 B(LdaZero), // | 1989 B(LdaZero), // |
| 1981 B(Star), R(1), // | 1990 B(Star), R(1), // |
| 1982 B(Ldar), R(0), // | 1991 B(Ldar), R(0), // |
| 1983 B(KeyedStoreICGeneric), R(2), R(1), // | 1992 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), // |
| 1984 B(LdaSmi8), U8(1), // | 1993 B(LdaSmi8), U8(1), // |
| 1985 B(Star), R(1), // | 1994 B(Star), R(1), // |
| 1986 B(Ldar), R(0), // | 1995 B(Ldar), R(0), // |
| 1987 B(Star), R(3), // | 1996 B(Star), R(3), // |
| 1988 B(LdaSmi8), U8(1), // | 1997 B(LdaSmi8), U8(1), // |
| 1989 B(Add), R(3), // | 1998 B(Add), R(3), // |
| 1990 B(KeyedStoreICGeneric), R(2), R(1), // | 1999 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), // |
| 1991 B(Ldar), R(2), // | 2000 B(Ldar), R(2), // |
| 1992 B(Return) // | 2001 B(Return) // |
| 1993 }, | 2002 }, |
| 1994 1, | 2003 1, |
| 1995 {InstanceType::FIXED_ARRAY_TYPE}}, | 2004 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 1996 {"return [ [ 1, 2 ], [ 3 ] ];", | 2005 {"return [ [ 1, 2 ], [ 3 ] ];", |
| 1997 0, | 2006 0, |
| 1998 1, | 2007 1, |
| 1999 6, | 2008 6, |
| 2000 { | 2009 { |
| 2001 B(LdaConstant), U8(0), // | 2010 B(LdaConstant), U8(0), // |
| 2002 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), // | 2011 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), // |
| 2003 B(Return) // | 2012 B(Return) // |
| 2004 }, | 2013 }, |
| 2005 1, | 2014 1, |
| 2006 {InstanceType::FIXED_ARRAY_TYPE}}, | 2015 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 2007 {"var a = 1; return [ [ a, 2 ], [ a + 2 ] ];", | 2016 {"var a = 1; return [ [ a, 2 ], [ a + 2 ] ];", |
| 2008 6 * kPointerSize, | 2017 6 * kPointerSize, |
| 2009 1, | 2018 1, |
| 2010 67, | 2019 71, |
| 2011 { | 2020 { |
| 2012 B(LdaSmi8), U8(1), // | 2021 B(LdaSmi8), U8(1), // |
| 2013 B(Star), R(0), // | 2022 B(Star), R(0), // |
| 2014 B(LdaConstant), U8(0), // | 2023 B(LdaConstant), U8(0), // |
| 2015 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), // | 2024 B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), // |
| 2016 B(Star), R(2), // | 2025 B(Star), R(2), // |
| 2017 B(LdaZero), // | 2026 B(LdaZero), // |
| 2018 B(Star), R(1), // | 2027 B(Star), R(1), // |
| 2019 B(LdaConstant), U8(1), // | 2028 B(LdaConstant), U8(1), // |
| 2020 B(CreateArrayLiteral), U8(0), U8(simple_flags), // | 2029 B(CreateArrayLiteral), U8(0), U8(simple_flags), // |
| 2021 B(Star), R(4), // | 2030 B(Star), R(4), // |
| 2022 B(LdaZero), // | 2031 B(LdaZero), // |
| 2023 B(Star), R(3), // | 2032 B(Star), R(3), // |
| 2024 B(Ldar), R(0), // | 2033 B(Ldar), R(0), // |
| 2025 B(KeyedStoreICGeneric), R(4), R(3), // | 2034 B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot1)), // |
| 2026 B(Ldar), R(4), // | 2035 B(Ldar), R(4), // |
| 2027 B(KeyedStoreICGeneric), R(2), R(1), // | 2036 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), // |
| 2028 B(LdaSmi8), U8(1), // | 2037 B(LdaSmi8), U8(1), // |
| 2029 B(Star), R(1), // | 2038 B(Star), R(1), // |
| 2030 B(LdaConstant), U8(2), // | 2039 B(LdaConstant), U8(2), // |
| 2031 B(CreateArrayLiteral), U8(1), U8(simple_flags), // | 2040 B(CreateArrayLiteral), U8(1), U8(simple_flags), // |
| 2032 B(Star), R(4), // | 2041 B(Star), R(4), // |
| 2033 B(LdaZero), // | 2042 B(LdaZero), // |
| 2034 B(Star), R(3), // | 2043 B(Star), R(3), // |
| 2035 B(Ldar), R(0), // | 2044 B(Ldar), R(0), // |
| 2036 B(Star), R(5), // | 2045 B(Star), R(5), // |
| 2037 B(LdaSmi8), U8(2), // | 2046 B(LdaSmi8), U8(2), // |
| 2038 B(Add), R(5), // | 2047 B(Add), R(5), // |
| 2039 B(KeyedStoreICGeneric), R(4), R(3), // | 2048 B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot2)), // |
| 2040 B(Ldar), R(4), // | 2049 B(Ldar), R(4), // |
| 2041 B(KeyedStoreICGeneric), R(2), R(1), // | 2050 B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), // |
| 2042 B(Ldar), R(2), // | 2051 B(Ldar), R(2), // |
| 2043 B(Return), // | 2052 B(Return), // |
| 2044 }, | 2053 }, |
| 2045 3, | 2054 3, |
| 2046 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, | 2055 {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE, |
| 2047 InstanceType::FIXED_ARRAY_TYPE}}, | 2056 InstanceType::FIXED_ARRAY_TYPE}}, |
| 2048 }; | 2057 }; |
| 2049 | 2058 |
| 2050 for (size_t i = 0; i < arraysize(snippets); i++) { | 2059 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2051 Handle<BytecodeArray> bytecode_array = | 2060 Handle<BytecodeArray> bytecode_array = |
| 2052 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 2061 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 2053 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2062 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2499 for (size_t i = 0; i < arraysize(snippets); i++) { | 2508 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2500 Handle<BytecodeArray> bytecode_array = | 2509 Handle<BytecodeArray> bytecode_array = |
| 2501 helper.MakeTopLevelBytecode(snippets[i].code_snippet); | 2510 helper.MakeTopLevelBytecode(snippets[i].code_snippet); |
| 2502 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2511 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2503 } | 2512 } |
| 2504 } | 2513 } |
| 2505 | 2514 |
| 2506 } // namespace interpreter | 2515 } // namespace interpreter |
| 2507 } // namespace internal | 2516 } // namespace internal |
| 2508 } // namespace v8 | 2517 } // namespace v8 |
| OLD | NEW |