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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
| 8 #include "test/cctest/test-api.h" |
| 9 |
8 #include "src/v8.h" | 10 #include "src/v8.h" |
9 | 11 |
10 #include "src/compilation-cache.h" | 12 #include "src/compilation-cache.h" |
11 #include "src/execution.h" | 13 #include "src/execution.h" |
12 #include "src/factory.h" | 14 #include "src/factory.h" |
13 #include "src/global-handles.h" | 15 #include "src/global-handles.h" |
14 #include "src/ic/stub-cache.h" | 16 #include "src/ic/stub-cache.h" |
15 #include "src/macro-assembler.h" | 17 #include "src/macro-assembler.h" |
16 #include "test/cctest/cctest.h" | |
17 | 18 |
18 using namespace v8::internal; | 19 using namespace v8::internal; |
19 | 20 |
20 | 21 |
21 // TODO(ishell): fix this once TransitionToPrototype stops generalizing | 22 // TODO(ishell): fix this once TransitionToPrototype stops generalizing |
22 // all field representations (similar to crbug/448711 where elements kind | 23 // all field representations (similar to crbug/448711 where elements kind |
23 // and observed transitions caused generalization of all field representations). | 24 // and observed transitions caused generalization of all field representations). |
24 const bool IS_PROTO_TRANS_ISSUE_FIXED = false; | 25 const bool IS_PROTO_TRANS_ISSUE_FIXED = false; |
25 | 26 |
26 | 27 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 280 |
280 Handle<Map> AddDataField(Handle<Map> map, PropertyAttributes attributes, | 281 Handle<Map> AddDataField(Handle<Map> map, PropertyAttributes attributes, |
281 Representation representation, | 282 Representation representation, |
282 Handle<HeapType> heap_type) { | 283 Handle<HeapType> heap_type) { |
283 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 284 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
284 int property_index = number_of_properties_++; | 285 int property_index = number_of_properties_++; |
285 SetDataField(property_index, attributes, representation, heap_type); | 286 SetDataField(property_index, attributes, representation, heap_type); |
286 | 287 |
287 Handle<String> name = MakeName("prop", property_index); | 288 Handle<String> name = MakeName("prop", property_index); |
288 return Map::CopyWithField(map, name, heap_type, attributes, representation, | 289 return Map::CopyWithField(map, name, heap_type, attributes, representation, |
289 INSERT_TRANSITION).ToHandleChecked(); | 290 INSERT_TRANSITION) |
| 291 .ToHandleChecked(); |
290 } | 292 } |
291 | 293 |
292 Handle<Map> AddDataConstant(Handle<Map> map, PropertyAttributes attributes, | 294 Handle<Map> AddDataConstant(Handle<Map> map, PropertyAttributes attributes, |
293 Handle<JSFunction> value) { | 295 Handle<JSFunction> value) { |
294 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 296 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
295 int property_index = number_of_properties_++; | 297 int property_index = number_of_properties_++; |
296 SetDataConstant(property_index, attributes, value); | 298 SetDataConstant(property_index, attributes, value); |
297 | 299 |
298 Handle<String> name = MakeName("prop", property_index); | 300 Handle<String> name = MakeName("prop", property_index); |
299 return Map::CopyWithConstant(map, name, value, attributes, | 301 return Map::CopyWithConstant(map, name, value, attributes, |
300 INSERT_TRANSITION).ToHandleChecked(); | 302 INSERT_TRANSITION) |
| 303 .ToHandleChecked(); |
301 } | 304 } |
302 | 305 |
303 Handle<Map> TransitionToDataField(Handle<Map> map, | 306 Handle<Map> TransitionToDataField(Handle<Map> map, |
304 PropertyAttributes attributes, | 307 PropertyAttributes attributes, |
305 Representation representation, | 308 Representation representation, |
306 Handle<HeapType> heap_type, | 309 Handle<HeapType> heap_type, |
307 Handle<Object> value) { | 310 Handle<Object> value) { |
308 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 311 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
309 int property_index = number_of_properties_++; | 312 int property_index = number_of_properties_++; |
310 SetDataField(property_index, attributes, representation, heap_type); | 313 SetDataField(property_index, attributes, representation, heap_type); |
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 CHECK(map->is_deprecated()); | 1579 CHECK(map->is_deprecated()); |
1577 CHECK(!split_map->is_deprecated()); | 1580 CHECK(!split_map->is_deprecated()); |
1578 CHECK(map2->is_stable()); | 1581 CHECK(map2->is_stable()); |
1579 CHECK(!map2->is_deprecated()); | 1582 CHECK(!map2->is_deprecated()); |
1580 | 1583 |
1581 // Fill in transition tree of |map2| so that it can't have more transitions. | 1584 // Fill in transition tree of |map2| so that it can't have more transitions. |
1582 for (int i = 0; i < TransitionArray::kMaxNumberOfTransitions; i++) { | 1585 for (int i = 0; i < TransitionArray::kMaxNumberOfTransitions; i++) { |
1583 CHECK(TransitionArray::CanHaveMoreTransitions(map2)); | 1586 CHECK(TransitionArray::CanHaveMoreTransitions(map2)); |
1584 Handle<String> name = MakeName("foo", i); | 1587 Handle<String> name = MakeName("foo", i); |
1585 Map::CopyWithField(map2, name, any_type, NONE, Representation::Smi(), | 1588 Map::CopyWithField(map2, name, any_type, NONE, Representation::Smi(), |
1586 INSERT_TRANSITION).ToHandleChecked(); | 1589 INSERT_TRANSITION) |
| 1590 .ToHandleChecked(); |
1587 } | 1591 } |
1588 CHECK(!TransitionArray::CanHaveMoreTransitions(map2)); | 1592 CHECK(!TransitionArray::CanHaveMoreTransitions(map2)); |
1589 | 1593 |
1590 // Try to update |map|, since there is no place for propX transition at |map2| | 1594 // Try to update |map|, since there is no place for propX transition at |map2| |
1591 // |map| should become "copy-generalized". | 1595 // |map| should become "copy-generalized". |
1592 Handle<Map> updated_map = Map::Update(map); | 1596 Handle<Map> updated_map = Map::Update(map); |
1593 CHECK(updated_map->GetBackPointer()->IsUndefined()); | 1597 CHECK(updated_map->GetBackPointer()->IsUndefined()); |
1594 | 1598 |
1595 for (int i = 0; i < kPropCount; i++) { | 1599 for (int i = 0; i < kPropCount; i++) { |
1596 expectations.SetDataField(i, Representation::Tagged(), any_type); | 1600 expectations.SetDataField(i, Representation::Tagged(), any_type); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 | 1748 |
1745 struct TestConfig { | 1749 struct TestConfig { |
1746 Handle<Map> Transition(Handle<Map> map) { | 1750 Handle<Map> Transition(Handle<Map> map) { |
1747 Isolate* isolate = CcTest::i_isolate(); | 1751 Isolate* isolate = CcTest::i_isolate(); |
1748 Handle<HeapType> any_type = HeapType::Any(isolate); | 1752 Handle<HeapType> any_type = HeapType::Any(isolate); |
1749 | 1753 |
1750 // Add one more transition to |map| in order to prevent descriptors | 1754 // Add one more transition to |map| in order to prevent descriptors |
1751 // ownership. | 1755 // ownership. |
1752 CHECK(map->owns_descriptors()); | 1756 CHECK(map->owns_descriptors()); |
1753 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, | 1757 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, |
1754 Representation::Smi(), | 1758 Representation::Smi(), INSERT_TRANSITION) |
1755 INSERT_TRANSITION).ToHandleChecked(); | 1759 .ToHandleChecked(); |
1756 CHECK(!map->owns_descriptors()); | 1760 CHECK(!map->owns_descriptors()); |
1757 | 1761 |
1758 return Map::CopyAsElementsKind(map, DICTIONARY_ELEMENTS, | 1762 return Map::CopyAsElementsKind(map, DICTIONARY_ELEMENTS, |
1759 INSERT_TRANSITION); | 1763 INSERT_TRANSITION); |
1760 } | 1764 } |
1761 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. | 1765 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. |
1762 bool generalizes_representations() const { return false; } | 1766 bool generalizes_representations() const { return false; } |
1763 bool is_non_equevalent_transition() const { return false; } | 1767 bool is_non_equevalent_transition() const { return false; } |
1764 }; | 1768 }; |
1765 TestConfig config; | 1769 TestConfig config; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1802 | 1806 |
1803 struct TestConfig { | 1807 struct TestConfig { |
1804 Handle<Map> Transition(Handle<Map> map) { | 1808 Handle<Map> Transition(Handle<Map> map) { |
1805 Isolate* isolate = CcTest::i_isolate(); | 1809 Isolate* isolate = CcTest::i_isolate(); |
1806 Handle<HeapType> any_type = HeapType::Any(isolate); | 1810 Handle<HeapType> any_type = HeapType::Any(isolate); |
1807 | 1811 |
1808 // Add one more transition to |map| in order to prevent descriptors | 1812 // Add one more transition to |map| in order to prevent descriptors |
1809 // ownership. | 1813 // ownership. |
1810 CHECK(map->owns_descriptors()); | 1814 CHECK(map->owns_descriptors()); |
1811 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, | 1815 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, |
1812 Representation::Smi(), | 1816 Representation::Smi(), INSERT_TRANSITION) |
1813 INSERT_TRANSITION).ToHandleChecked(); | 1817 .ToHandleChecked(); |
1814 CHECK(!map->owns_descriptors()); | 1818 CHECK(!map->owns_descriptors()); |
1815 | 1819 |
1816 return Map::CopyForObserved(map); | 1820 return Map::CopyForObserved(map); |
1817 } | 1821 } |
1818 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. | 1822 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. |
1819 bool generalizes_representations() const { return false; } | 1823 bool generalizes_representations() const { return false; } |
1820 bool is_non_equevalent_transition() const { return true; } | 1824 bool is_non_equevalent_transition() const { return true; } |
1821 }; | 1825 }; |
1822 TestConfig config; | 1826 TestConfig config; |
1823 TestGeneralizeRepresentationWithSpecialTransition( | 1827 TestGeneralizeRepresentationWithSpecialTransition( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 } | 1883 } |
1880 | 1884 |
1881 Handle<Map> Transition(Handle<Map> map) { | 1885 Handle<Map> Transition(Handle<Map> map) { |
1882 Isolate* isolate = CcTest::i_isolate(); | 1886 Isolate* isolate = CcTest::i_isolate(); |
1883 Handle<HeapType> any_type = HeapType::Any(isolate); | 1887 Handle<HeapType> any_type = HeapType::Any(isolate); |
1884 | 1888 |
1885 // Add one more transition to |map| in order to prevent descriptors | 1889 // Add one more transition to |map| in order to prevent descriptors |
1886 // ownership. | 1890 // ownership. |
1887 CHECK(map->owns_descriptors()); | 1891 CHECK(map->owns_descriptors()); |
1888 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, | 1892 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, |
1889 Representation::Smi(), | 1893 Representation::Smi(), INSERT_TRANSITION) |
1890 INSERT_TRANSITION).ToHandleChecked(); | 1894 .ToHandleChecked(); |
1891 CHECK(!map->owns_descriptors()); | 1895 CHECK(!map->owns_descriptors()); |
1892 | 1896 |
1893 return Map::TransitionToPrototype(map, prototype_, REGULAR_PROTOTYPE); | 1897 return Map::TransitionToPrototype(map, prototype_, REGULAR_PROTOTYPE); |
1894 } | 1898 } |
1895 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. | 1899 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. |
1896 bool generalizes_representations() const { | 1900 bool generalizes_representations() const { |
1897 return !IS_PROTO_TRANS_ISSUE_FIXED; | 1901 return !IS_PROTO_TRANS_ISSUE_FIXED; |
1898 } | 1902 } |
1899 bool is_non_equevalent_transition() const { return true; } | 1903 bool is_non_equevalent_transition() const { return true; } |
1900 }; | 1904 }; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2173 Handle<AccessorPair> pair = CreateAccessorPair(true, true); | 2177 Handle<AccessorPair> pair = CreateAccessorPair(true, true); |
2174 TransitionToAccessorConstantOperator transition_op(pair); | 2178 TransitionToAccessorConstantOperator transition_op(pair); |
2175 | 2179 |
2176 SameMapChecker checker; | 2180 SameMapChecker checker; |
2177 TestTransitionTo(transition_op, transition_op, checker); | 2181 TestTransitionTo(transition_op, transition_op, checker); |
2178 } | 2182 } |
2179 | 2183 |
2180 | 2184 |
2181 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. | 2185 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. |
2182 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) | 2186 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) |
OLD | NEW |