| 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" | 8 #include "test/cctest/test-api.h" |
| 9 | 9 |
| 10 #include "src/v8.h" | 10 #include "src/v8.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return true; | 81 return true; |
| 82 } | 82 } |
| 83 | 83 |
| 84 | 84 |
| 85 class Expectations { | 85 class Expectations { |
| 86 static const int MAX_PROPERTIES = 10; | 86 static const int MAX_PROPERTIES = 10; |
| 87 Isolate* isolate_; | 87 Isolate* isolate_; |
| 88 PropertyType types_[MAX_PROPERTIES]; | 88 PropertyType types_[MAX_PROPERTIES]; |
| 89 PropertyAttributes attributes_[MAX_PROPERTIES]; | 89 PropertyAttributes attributes_[MAX_PROPERTIES]; |
| 90 Representation representations_[MAX_PROPERTIES]; | 90 Representation representations_[MAX_PROPERTIES]; |
| 91 // HeapType for kField, value for DATA_CONSTANT and getter for | 91 // FieldType for kField, value for DATA_CONSTANT and getter for |
| 92 // ACCESSOR_CONSTANT. | 92 // ACCESSOR_CONSTANT. |
| 93 Handle<Object> values_[MAX_PROPERTIES]; | 93 Handle<Object> values_[MAX_PROPERTIES]; |
| 94 // Setter for ACCESSOR_CONSTANT. | 94 // Setter for ACCESSOR_CONSTANT. |
| 95 Handle<Object> setter_values_[MAX_PROPERTIES]; | 95 Handle<Object> setter_values_[MAX_PROPERTIES]; |
| 96 int number_of_properties_; | 96 int number_of_properties_; |
| 97 | 97 |
| 98 public: | 98 public: |
| 99 explicit Expectations(Isolate* isolate) | 99 explicit Expectations(Isolate* isolate) |
| 100 : isolate_(isolate), number_of_properties_(0) {} | 100 : isolate_(isolate), number_of_properties_(0) {} |
| 101 | 101 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 case ACCESSOR: | 135 case ACCESSOR: |
| 136 os << "accessor"; | 136 os << "accessor"; |
| 137 break; | 137 break; |
| 138 } | 138 } |
| 139 os << ": " << representations_[i].Mnemonic(); | 139 os << ": " << representations_[i].Mnemonic(); |
| 140 os << ", attrs: " << attributes_[i] << ")\n"; | 140 os << ", attrs: " << attributes_[i] << ")\n"; |
| 141 } | 141 } |
| 142 os << "\n"; | 142 os << "\n"; |
| 143 } | 143 } |
| 144 | 144 |
| 145 Handle<HeapType> GetFieldType(int index) { | 145 Handle<FieldType> GetFieldType(int index) { |
| 146 CHECK(index < MAX_PROPERTIES); | 146 CHECK(index < MAX_PROPERTIES); |
| 147 CHECK(types_[index] == DATA || types_[index] == ACCESSOR); | 147 CHECK(types_[index] == DATA || types_[index] == ACCESSOR); |
| 148 return Handle<HeapType>::cast(values_[index]); | 148 return Handle<FieldType>::cast(values_[index]); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void SetDataField(int index, PropertyAttributes attrs, | 151 void SetDataField(int index, PropertyAttributes attrs, |
| 152 Representation representation, Handle<HeapType> value) { | 152 Representation representation, Handle<FieldType> value) { |
| 153 Init(index, DATA, attrs, representation, value); | 153 Init(index, DATA, attrs, representation, value); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void SetDataField(int index, Representation representation, | 156 void SetDataField(int index, Representation representation, |
| 157 Handle<HeapType> value) { | 157 Handle<FieldType> value) { |
| 158 SetDataField(index, attributes_[index], representation, value); | 158 SetDataField(index, attributes_[index], representation, value); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void SetAccessorField(int index, PropertyAttributes attrs) { | 161 void SetAccessorField(int index, PropertyAttributes attrs) { |
| 162 Init(index, ACCESSOR, attrs, Representation::Tagged(), | 162 Init(index, ACCESSOR, attrs, Representation::Tagged(), |
| 163 HeapType::Any(isolate_)); | 163 FieldType::Any(isolate_)); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void SetAccessorField(int index) { | 166 void SetAccessorField(int index) { |
| 167 SetAccessorField(index, attributes_[index]); | 167 SetAccessorField(index, attributes_[index]); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void SetDataConstant(int index, PropertyAttributes attrs, | 170 void SetDataConstant(int index, PropertyAttributes attrs, |
| 171 Handle<JSFunction> value) { | 171 Handle<JSFunction> value) { |
| 172 Init(index, DATA_CONSTANT, attrs, Representation::HeapObject(), value); | 172 Init(index, DATA_CONSTANT, attrs, Representation::HeapObject(), value); |
| 173 } | 173 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 void SetAccessorConstant(int index, Handle<AccessorPair> pair) { | 209 void SetAccessorConstant(int index, Handle<AccessorPair> pair) { |
| 210 Handle<Object> getter = handle(pair->getter(), isolate_); | 210 Handle<Object> getter = handle(pair->getter(), isolate_); |
| 211 Handle<Object> setter = handle(pair->setter(), isolate_); | 211 Handle<Object> setter = handle(pair->setter(), isolate_); |
| 212 SetAccessorConstant(index, getter, setter); | 212 SetAccessorConstant(index, getter, setter); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void GeneralizeRepresentation(int index) { | 215 void GeneralizeRepresentation(int index) { |
| 216 CHECK(index < number_of_properties_); | 216 CHECK(index < number_of_properties_); |
| 217 representations_[index] = Representation::Tagged(); | 217 representations_[index] = Representation::Tagged(); |
| 218 if (types_[index] == DATA || types_[index] == ACCESSOR) { | 218 if (types_[index] == DATA || types_[index] == ACCESSOR) { |
| 219 values_[index] = HeapType::Any(isolate_); | 219 values_[index] = FieldType::Any(isolate_); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 | 223 |
| 224 bool Check(DescriptorArray* descriptors, int descriptor) const { | 224 bool Check(DescriptorArray* descriptors, int descriptor) const { |
| 225 PropertyType type = types_[descriptor]; | 225 PropertyType type = types_[descriptor]; |
| 226 if (!EqualDetails(descriptors, descriptor, type, attributes_[descriptor], | 226 if (!EqualDetails(descriptors, descriptor, type, attributes_[descriptor], |
| 227 representations_[descriptor])) { | 227 representations_[descriptor])) { |
| 228 return false; | 228 return false; |
| 229 } | 229 } |
| 230 Object* value = descriptors->GetValue(descriptor); | 230 Object* value = descriptors->GetValue(descriptor); |
| 231 Object* expected_value = *values_[descriptor]; | 231 Object* expected_value = *values_[descriptor]; |
| 232 switch (type) { | 232 switch (type) { |
| 233 case DATA: | 233 case DATA: |
| 234 case ACCESSOR: { | 234 case ACCESSOR: { |
| 235 HeapType* type = descriptors->GetFieldType(descriptor); | 235 FieldType* type = descriptors->GetFieldType(descriptor); |
| 236 return HeapType::cast(expected_value)->Equals(type); | 236 return FieldType::cast(expected_value) == type; |
| 237 } | 237 } |
| 238 | 238 |
| 239 case DATA_CONSTANT: | 239 case DATA_CONSTANT: |
| 240 return value == expected_value; | 240 return value == expected_value; |
| 241 | 241 |
| 242 case ACCESSOR_CONSTANT: { | 242 case ACCESSOR_CONSTANT: { |
| 243 if (value == expected_value) return true; | 243 if (value == expected_value) return true; |
| 244 if (!value->IsAccessorPair()) return false; | 244 if (!value->IsAccessorPair()) return false; |
| 245 AccessorPair* pair = AccessorPair::cast(value); | 245 AccessorPair* pair = AccessorPair::cast(value); |
| 246 return pair->Equals(expected_value, *setter_values_[descriptor]); | 246 return pair->Equals(expected_value, *setter_values_[descriptor]); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 273 bool Check(Map* map) const { return Check(map, number_of_properties_); } | 273 bool Check(Map* map) const { return Check(map, number_of_properties_); } |
| 274 | 274 |
| 275 | 275 |
| 276 // | 276 // |
| 277 // Helper methods for initializing expectations and adding properties to | 277 // Helper methods for initializing expectations and adding properties to |
| 278 // given |map|. | 278 // given |map|. |
| 279 // | 279 // |
| 280 | 280 |
| 281 Handle<Map> AddDataField(Handle<Map> map, PropertyAttributes attributes, | 281 Handle<Map> AddDataField(Handle<Map> map, PropertyAttributes attributes, |
| 282 Representation representation, | 282 Representation representation, |
| 283 Handle<HeapType> heap_type) { | 283 Handle<FieldType> heap_type) { |
| 284 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 284 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
| 285 int property_index = number_of_properties_++; | 285 int property_index = number_of_properties_++; |
| 286 SetDataField(property_index, attributes, representation, heap_type); | 286 SetDataField(property_index, attributes, representation, heap_type); |
| 287 | 287 |
| 288 Handle<String> name = MakeName("prop", property_index); | 288 Handle<String> name = MakeName("prop", property_index); |
| 289 return Map::CopyWithField(map, name, heap_type, attributes, representation, | 289 return Map::CopyWithField(map, name, heap_type, attributes, representation, |
| 290 INSERT_TRANSITION) | 290 INSERT_TRANSITION) |
| 291 .ToHandleChecked(); | 291 .ToHandleChecked(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 Handle<Map> AddDataConstant(Handle<Map> map, PropertyAttributes attributes, | 294 Handle<Map> AddDataConstant(Handle<Map> map, PropertyAttributes attributes, |
| 295 Handle<JSFunction> value) { | 295 Handle<JSFunction> value) { |
| 296 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 296 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
| 297 int property_index = number_of_properties_++; | 297 int property_index = number_of_properties_++; |
| 298 SetDataConstant(property_index, attributes, value); | 298 SetDataConstant(property_index, attributes, value); |
| 299 | 299 |
| 300 Handle<String> name = MakeName("prop", property_index); | 300 Handle<String> name = MakeName("prop", property_index); |
| 301 return Map::CopyWithConstant(map, name, value, attributes, | 301 return Map::CopyWithConstant(map, name, value, attributes, |
| 302 INSERT_TRANSITION) | 302 INSERT_TRANSITION) |
| 303 .ToHandleChecked(); | 303 .ToHandleChecked(); |
| 304 } | 304 } |
| 305 | 305 |
| 306 Handle<Map> TransitionToDataField(Handle<Map> map, | 306 Handle<Map> TransitionToDataField(Handle<Map> map, |
| 307 PropertyAttributes attributes, | 307 PropertyAttributes attributes, |
| 308 Representation representation, | 308 Representation representation, |
| 309 Handle<HeapType> heap_type, | 309 Handle<FieldType> heap_type, |
| 310 Handle<Object> value) { | 310 Handle<Object> value) { |
| 311 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 311 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
| 312 int property_index = number_of_properties_++; | 312 int property_index = number_of_properties_++; |
| 313 SetDataField(property_index, attributes, representation, heap_type); | 313 SetDataField(property_index, attributes, representation, heap_type); |
| 314 | 314 |
| 315 Handle<String> name = MakeName("prop", property_index); | 315 Handle<String> name = MakeName("prop", property_index); |
| 316 return Map::TransitionToDataProperty( | 316 return Map::TransitionToDataProperty( |
| 317 map, name, value, attributes, Object::CERTAINLY_NOT_STORE_FROM_KEYED); | 317 map, name, value, attributes, Object::CERTAINLY_NOT_STORE_FROM_KEYED); |
| 318 } | 318 } |
| 319 | 319 |
| 320 Handle<Map> TransitionToDataConstant(Handle<Map> map, | 320 Handle<Map> TransitionToDataConstant(Handle<Map> map, |
| 321 PropertyAttributes attributes, | 321 PropertyAttributes attributes, |
| 322 Handle<JSFunction> value) { | 322 Handle<JSFunction> value) { |
| 323 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 323 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
| 324 int property_index = number_of_properties_++; | 324 int property_index = number_of_properties_++; |
| 325 SetDataConstant(property_index, attributes, value); | 325 SetDataConstant(property_index, attributes, value); |
| 326 | 326 |
| 327 Handle<String> name = MakeName("prop", property_index); | 327 Handle<String> name = MakeName("prop", property_index); |
| 328 return Map::TransitionToDataProperty( | 328 return Map::TransitionToDataProperty( |
| 329 map, name, value, attributes, Object::CERTAINLY_NOT_STORE_FROM_KEYED); | 329 map, name, value, attributes, Object::CERTAINLY_NOT_STORE_FROM_KEYED); |
| 330 } | 330 } |
| 331 | 331 |
| 332 Handle<Map> FollowDataTransition(Handle<Map> map, | 332 Handle<Map> FollowDataTransition(Handle<Map> map, |
| 333 PropertyAttributes attributes, | 333 PropertyAttributes attributes, |
| 334 Representation representation, | 334 Representation representation, |
| 335 Handle<HeapType> heap_type) { | 335 Handle<FieldType> heap_type) { |
| 336 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 336 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
| 337 int property_index = number_of_properties_++; | 337 int property_index = number_of_properties_++; |
| 338 SetDataField(property_index, attributes, representation, heap_type); | 338 SetDataField(property_index, attributes, representation, heap_type); |
| 339 | 339 |
| 340 Handle<String> name = MakeName("prop", property_index); | 340 Handle<String> name = MakeName("prop", property_index); |
| 341 Map* target = | 341 Map* target = |
| 342 TransitionArray::SearchTransition(*map, kData, *name, attributes); | 342 TransitionArray::SearchTransition(*map, kData, *name, attributes); |
| 343 CHECK(target != NULL); | 343 CHECK(target != NULL); |
| 344 return handle(target); | 344 return handle(target); |
| 345 } | 345 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 414 |
| 415 //////////////////////////////////////////////////////////////////////////////// | 415 //////////////////////////////////////////////////////////////////////////////// |
| 416 // A set of tests for property reconfiguration that makes new transition tree | 416 // A set of tests for property reconfiguration that makes new transition tree |
| 417 // branch. | 417 // branch. |
| 418 // | 418 // |
| 419 | 419 |
| 420 TEST(ReconfigureAccessorToNonExistingDataField) { | 420 TEST(ReconfigureAccessorToNonExistingDataField) { |
| 421 CcTest::InitializeVM(); | 421 CcTest::InitializeVM(); |
| 422 v8::HandleScope scope(CcTest::isolate()); | 422 v8::HandleScope scope(CcTest::isolate()); |
| 423 Isolate* isolate = CcTest::i_isolate(); | 423 Isolate* isolate = CcTest::i_isolate(); |
| 424 Handle<HeapType> any_type = HeapType::Any(isolate); | 424 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 425 Handle<HeapType> none_type = HeapType::None(isolate); | 425 Handle<FieldType> none_type = FieldType::None(isolate); |
| 426 Handle<AccessorPair> pair = CreateAccessorPair(true, true); | 426 Handle<AccessorPair> pair = CreateAccessorPair(true, true); |
| 427 | 427 |
| 428 Expectations expectations(isolate); | 428 Expectations expectations(isolate); |
| 429 | 429 |
| 430 // Create a map, add required properties to it and initialize expectations. | 430 // Create a map, add required properties to it and initialize expectations. |
| 431 Handle<Map> initial_map = Map::Create(isolate, 0); | 431 Handle<Map> initial_map = Map::Create(isolate, 0); |
| 432 Handle<Map> map = initial_map; | 432 Handle<Map> map = initial_map; |
| 433 map = expectations.AddAccessorConstant(map, NONE, pair); | 433 map = expectations.AddAccessorConstant(map, NONE, pair); |
| 434 | 434 |
| 435 CHECK(!map->is_deprecated()); | 435 CHECK(!map->is_deprecated()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 // {} - p0 - p1 - p2: |detach_point_map| | 526 // {} - p0 - p1 - p2: |detach_point_map| |
| 527 // | | 527 // | |
| 528 // X - detached at |detach_property_at_index| | 528 // X - detached at |detach_property_at_index| |
| 529 // | | 529 // | |
| 530 // + - p3 - p4: |map| | 530 // + - p3 - p4: |map| |
| 531 // | 531 // |
| 532 // Detaching does not happen if |detach_property_at_index| is -1. | 532 // Detaching does not happen if |detach_property_at_index| is -1. |
| 533 // | 533 // |
| 534 static void TestGeneralizeRepresentation( | 534 static void TestGeneralizeRepresentation( |
| 535 int detach_property_at_index, int property_index, | 535 int detach_property_at_index, int property_index, |
| 536 Representation from_representation, Handle<HeapType> from_type, | 536 Representation from_representation, Handle<FieldType> from_type, |
| 537 Representation to_representation, Handle<HeapType> to_type, | 537 Representation to_representation, Handle<FieldType> to_type, |
| 538 Representation expected_representation, Handle<HeapType> expected_type, | 538 Representation expected_representation, Handle<FieldType> expected_type, |
| 539 bool expected_deprecation, bool expected_field_type_dependency) { | 539 bool expected_deprecation, bool expected_field_type_dependency) { |
| 540 Isolate* isolate = CcTest::i_isolate(); | 540 Isolate* isolate = CcTest::i_isolate(); |
| 541 Handle<HeapType> any_type = HeapType::Any(isolate); | 541 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 542 | 542 |
| 543 CHECK(detach_property_at_index >= -1 && | 543 CHECK(detach_property_at_index >= -1 && |
| 544 detach_property_at_index < kPropCount); | 544 detach_property_at_index < kPropCount); |
| 545 CHECK(property_index < kPropCount); | 545 CHECK(property_index < kPropCount); |
| 546 CHECK_NE(detach_property_at_index, property_index); | 546 CHECK_NE(detach_property_at_index, property_index); |
| 547 | 547 |
| 548 const bool is_detached_map = detach_property_at_index >= 0; | 548 const bool is_detached_map = detach_property_at_index >= 0; |
| 549 | 549 |
| 550 Expectations expectations(isolate); | 550 Expectations expectations(isolate); |
| 551 | 551 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 } | 632 } |
| 633 } | 633 } |
| 634 | 634 |
| 635 info.dependencies()->Rollback(); // Properly cleanup compilation info. | 635 info.dependencies()->Rollback(); // Properly cleanup compilation info. |
| 636 | 636 |
| 637 // Update all deprecated maps and check that they are now the same. | 637 // Update all deprecated maps and check that they are now the same. |
| 638 Handle<Map> updated_map = Map::Update(map); | 638 Handle<Map> updated_map = Map::Update(map); |
| 639 CHECK_EQ(*new_map, *updated_map); | 639 CHECK_EQ(*new_map, *updated_map); |
| 640 } | 640 } |
| 641 | 641 |
| 642 | |
| 643 static void TestGeneralizeRepresentation( | 642 static void TestGeneralizeRepresentation( |
| 644 Representation from_representation, Handle<HeapType> from_type, | 643 Representation from_representation, Handle<FieldType> from_type, |
| 645 Representation to_representation, Handle<HeapType> to_type, | 644 Representation to_representation, Handle<FieldType> to_type, |
| 646 Representation expected_representation, Handle<HeapType> expected_type, | 645 Representation expected_representation, Handle<FieldType> expected_type, |
| 647 bool expected_deprecation, bool expected_field_type_dependency) { | 646 bool expected_deprecation, bool expected_field_type_dependency) { |
| 648 // Check the cases when the map being reconfigured is a part of the | 647 // Check the cases when the map being reconfigured is a part of the |
| 649 // transition tree. | 648 // transition tree. |
| 650 STATIC_ASSERT(kPropCount > 4); | 649 STATIC_ASSERT(kPropCount > 4); |
| 651 int indices[] = {0, 2, kPropCount - 1}; | 650 int indices[] = {0, 2, kPropCount - 1}; |
| 652 for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { | 651 for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { |
| 653 TestGeneralizeRepresentation( | 652 TestGeneralizeRepresentation( |
| 654 -1, indices[i], from_representation, from_type, to_representation, | 653 -1, indices[i], from_representation, from_type, to_representation, |
| 655 to_type, expected_representation, expected_type, expected_deprecation, | 654 to_type, expected_representation, expected_type, expected_deprecation, |
| 656 expected_field_type_dependency); | 655 expected_field_type_dependency); |
| 657 } | 656 } |
| 658 | 657 |
| 659 if (!from_representation.IsNone()) { | 658 if (!from_representation.IsNone()) { |
| 660 // Check the cases when the map being reconfigured is NOT a part of the | 659 // Check the cases when the map being reconfigured is NOT a part of the |
| 661 // transition tree. "None -> anything" representation changes make sense | 660 // transition tree. "None -> anything" representation changes make sense |
| 662 // only for "attached" maps. | 661 // only for "attached" maps. |
| 663 int indices[] = {0, kPropCount - 1}; | 662 int indices[] = {0, kPropCount - 1}; |
| 664 for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { | 663 for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { |
| 665 TestGeneralizeRepresentation( | 664 TestGeneralizeRepresentation( |
| 666 indices[i], 2, from_representation, from_type, to_representation, | 665 indices[i], 2, from_representation, from_type, to_representation, |
| 667 to_type, expected_representation, expected_type, expected_deprecation, | 666 to_type, expected_representation, expected_type, expected_deprecation, |
| 668 expected_field_type_dependency); | 667 expected_field_type_dependency); |
| 669 } | 668 } |
| 670 | 669 |
| 671 // Check that reconfiguration to the very same field works correctly. | 670 // Check that reconfiguration to the very same field works correctly. |
| 672 Representation representation = from_representation; | 671 Representation representation = from_representation; |
| 673 Handle<HeapType> type = from_type; | 672 Handle<FieldType> type = from_type; |
| 674 TestGeneralizeRepresentation(-1, 2, representation, type, representation, | 673 TestGeneralizeRepresentation(-1, 2, representation, type, representation, |
| 675 type, representation, type, false, false); | 674 type, representation, type, false, false); |
| 676 } | 675 } |
| 677 } | 676 } |
| 678 | 677 |
| 679 | |
| 680 static void TestGeneralizeRepresentation(Representation from_representation, | 678 static void TestGeneralizeRepresentation(Representation from_representation, |
| 681 Handle<HeapType> from_type, | 679 Handle<FieldType> from_type, |
| 682 Representation to_representation, | 680 Representation to_representation, |
| 683 Handle<HeapType> to_type, | 681 Handle<FieldType> to_type, |
| 684 Representation expected_representation, | 682 Representation expected_representation, |
| 685 Handle<HeapType> expected_type) { | 683 Handle<FieldType> expected_type) { |
| 686 const bool expected_deprecation = true; | 684 const bool expected_deprecation = true; |
| 687 const bool expected_field_type_dependency = false; | 685 const bool expected_field_type_dependency = false; |
| 688 | 686 |
| 689 TestGeneralizeRepresentation( | 687 TestGeneralizeRepresentation( |
| 690 from_representation, from_type, to_representation, to_type, | 688 from_representation, from_type, to_representation, to_type, |
| 691 expected_representation, expected_type, expected_deprecation, | 689 expected_representation, expected_type, expected_deprecation, |
| 692 expected_field_type_dependency); | 690 expected_field_type_dependency); |
| 693 } | 691 } |
| 694 | 692 |
| 695 | |
| 696 static void TestGeneralizeRepresentationTrivial( | 693 static void TestGeneralizeRepresentationTrivial( |
| 697 Representation from_representation, Handle<HeapType> from_type, | 694 Representation from_representation, Handle<FieldType> from_type, |
| 698 Representation to_representation, Handle<HeapType> to_type, | 695 Representation to_representation, Handle<FieldType> to_type, |
| 699 Representation expected_representation, Handle<HeapType> expected_type, | 696 Representation expected_representation, Handle<FieldType> expected_type, |
| 700 bool expected_field_type_dependency = true) { | 697 bool expected_field_type_dependency = true) { |
| 701 const bool expected_deprecation = false; | 698 const bool expected_deprecation = false; |
| 702 | 699 |
| 703 TestGeneralizeRepresentation( | 700 TestGeneralizeRepresentation( |
| 704 from_representation, from_type, to_representation, to_type, | 701 from_representation, from_type, to_representation, to_type, |
| 705 expected_representation, expected_type, expected_deprecation, | 702 expected_representation, expected_type, expected_deprecation, |
| 706 expected_field_type_dependency); | 703 expected_field_type_dependency); |
| 707 } | 704 } |
| 708 | 705 |
| 709 | 706 |
| 710 TEST(GeneralizeRepresentationSmiToDouble) { | 707 TEST(GeneralizeRepresentationSmiToDouble) { |
| 711 CcTest::InitializeVM(); | 708 CcTest::InitializeVM(); |
| 712 v8::HandleScope scope(CcTest::isolate()); | 709 v8::HandleScope scope(CcTest::isolate()); |
| 713 Isolate* isolate = CcTest::i_isolate(); | 710 Isolate* isolate = CcTest::i_isolate(); |
| 714 Handle<HeapType> any_type = HeapType::Any(isolate); | 711 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 715 | 712 |
| 716 TestGeneralizeRepresentation(Representation::Smi(), any_type, | 713 TestGeneralizeRepresentation(Representation::Smi(), any_type, |
| 717 Representation::Double(), any_type, | 714 Representation::Double(), any_type, |
| 718 Representation::Double(), any_type); | 715 Representation::Double(), any_type); |
| 719 } | 716 } |
| 720 | 717 |
| 721 | 718 |
| 722 TEST(GeneralizeRepresentationSmiToTagged) { | 719 TEST(GeneralizeRepresentationSmiToTagged) { |
| 723 CcTest::InitializeVM(); | 720 CcTest::InitializeVM(); |
| 724 v8::HandleScope scope(CcTest::isolate()); | 721 v8::HandleScope scope(CcTest::isolate()); |
| 725 Isolate* isolate = CcTest::i_isolate(); | 722 Isolate* isolate = CcTest::i_isolate(); |
| 726 Handle<HeapType> any_type = HeapType::Any(isolate); | 723 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 727 Handle<HeapType> value_type = | 724 Handle<FieldType> value_type = |
| 728 HeapType::Class(Map::Create(isolate, 0), isolate); | 725 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 729 | 726 |
| 730 TestGeneralizeRepresentation(Representation::Smi(), any_type, | 727 TestGeneralizeRepresentation(Representation::Smi(), any_type, |
| 731 Representation::HeapObject(), value_type, | 728 Representation::HeapObject(), value_type, |
| 732 Representation::Tagged(), any_type); | 729 Representation::Tagged(), any_type); |
| 733 } | 730 } |
| 734 | 731 |
| 735 | 732 |
| 736 TEST(GeneralizeRepresentationDoubleToTagged) { | 733 TEST(GeneralizeRepresentationDoubleToTagged) { |
| 737 CcTest::InitializeVM(); | 734 CcTest::InitializeVM(); |
| 738 v8::HandleScope scope(CcTest::isolate()); | 735 v8::HandleScope scope(CcTest::isolate()); |
| 739 Isolate* isolate = CcTest::i_isolate(); | 736 Isolate* isolate = CcTest::i_isolate(); |
| 740 Handle<HeapType> any_type = HeapType::Any(isolate); | 737 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 741 Handle<HeapType> value_type = | 738 Handle<FieldType> value_type = |
| 742 HeapType::Class(Map::Create(isolate, 0), isolate); | 739 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 743 | 740 |
| 744 TestGeneralizeRepresentation(Representation::Double(), any_type, | 741 TestGeneralizeRepresentation(Representation::Double(), any_type, |
| 745 Representation::HeapObject(), value_type, | 742 Representation::HeapObject(), value_type, |
| 746 Representation::Tagged(), any_type); | 743 Representation::Tagged(), any_type); |
| 747 } | 744 } |
| 748 | 745 |
| 749 | 746 |
| 750 TEST(GeneralizeRepresentationHeapObjectToTagged) { | 747 TEST(GeneralizeRepresentationHeapObjectToTagged) { |
| 751 CcTest::InitializeVM(); | 748 CcTest::InitializeVM(); |
| 752 v8::HandleScope scope(CcTest::isolate()); | 749 v8::HandleScope scope(CcTest::isolate()); |
| 753 Isolate* isolate = CcTest::i_isolate(); | 750 Isolate* isolate = CcTest::i_isolate(); |
| 754 Handle<HeapType> any_type = HeapType::Any(isolate); | 751 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 755 Handle<HeapType> value_type = | 752 Handle<FieldType> value_type = |
| 756 HeapType::Class(Map::Create(isolate, 0), isolate); | 753 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 757 | 754 |
| 758 TestGeneralizeRepresentation(Representation::HeapObject(), value_type, | 755 TestGeneralizeRepresentation(Representation::HeapObject(), value_type, |
| 759 Representation::Smi(), any_type, | 756 Representation::Smi(), any_type, |
| 760 Representation::Tagged(), any_type); | 757 Representation::Tagged(), any_type); |
| 761 } | 758 } |
| 762 | 759 |
| 763 | 760 |
| 764 TEST(GeneralizeRepresentationHeapObjectToHeapObject) { | 761 TEST(GeneralizeRepresentationHeapObjectToHeapObject) { |
| 765 CcTest::InitializeVM(); | 762 CcTest::InitializeVM(); |
| 766 v8::HandleScope scope(CcTest::isolate()); | 763 v8::HandleScope scope(CcTest::isolate()); |
| 767 Isolate* isolate = CcTest::i_isolate(); | 764 Isolate* isolate = CcTest::i_isolate(); |
| 768 Handle<HeapType> any_type = HeapType::Any(isolate); | 765 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 769 | 766 |
| 770 const int kMaxClassesPerFieldType = 1; | 767 Handle<FieldType> current_type = |
| 771 Handle<HeapType> current_type = | 768 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 772 HeapType::Class(Map::Create(isolate, 0), isolate); | |
| 773 | 769 |
| 774 for (int i = 0; i < kMaxClassesPerFieldType; i++) { | 770 Handle<FieldType> new_type = |
| 775 Handle<HeapType> new_type = | 771 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 776 HeapType::Class(Map::Create(isolate, 0), isolate); | |
| 777 | 772 |
| 778 Handle<HeapType> expected_type = | 773 Handle<FieldType> expected_type = any_type; |
| 779 (i < kMaxClassesPerFieldType - 1) | |
| 780 ? HeapType::Union(current_type, new_type, isolate) | |
| 781 : any_type; | |
| 782 | 774 |
| 783 TestGeneralizeRepresentationTrivial( | 775 TestGeneralizeRepresentationTrivial( |
| 784 Representation::HeapObject(), current_type, | 776 Representation::HeapObject(), current_type, |
| 785 Representation::HeapObject(), new_type, Representation::HeapObject(), | 777 Representation::HeapObject(), new_type, Representation::HeapObject(), |
| 786 expected_type); | 778 expected_type); |
| 787 current_type = expected_type; | 779 current_type = expected_type; |
| 788 } | |
| 789 | 780 |
| 790 Handle<HeapType> new_type = HeapType::Class(Map::Create(isolate, 0), isolate); | 781 new_type = FieldType::Class(Map::Create(isolate, 0), isolate); |
| 791 | 782 |
| 792 TestGeneralizeRepresentationTrivial( | 783 TestGeneralizeRepresentationTrivial( |
| 793 Representation::HeapObject(), any_type, Representation::HeapObject(), | 784 Representation::HeapObject(), any_type, Representation::HeapObject(), |
| 794 new_type, Representation::HeapObject(), any_type, false); | 785 new_type, Representation::HeapObject(), any_type, false); |
| 795 } | 786 } |
| 796 | 787 |
| 797 | 788 |
| 798 TEST(GeneralizeRepresentationNoneToSmi) { | 789 TEST(GeneralizeRepresentationNoneToSmi) { |
| 799 CcTest::InitializeVM(); | 790 CcTest::InitializeVM(); |
| 800 v8::HandleScope scope(CcTest::isolate()); | 791 v8::HandleScope scope(CcTest::isolate()); |
| 801 Isolate* isolate = CcTest::i_isolate(); | 792 Isolate* isolate = CcTest::i_isolate(); |
| 802 Handle<HeapType> none_type = HeapType::None(isolate); | 793 Handle<FieldType> none_type = FieldType::None(isolate); |
| 803 Handle<HeapType> any_type = HeapType::Any(isolate); | 794 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 804 | 795 |
| 805 // None -> Smi representation change is trivial. | 796 // None -> Smi representation change is trivial. |
| 806 TestGeneralizeRepresentationTrivial(Representation::None(), none_type, | 797 TestGeneralizeRepresentationTrivial(Representation::None(), none_type, |
| 807 Representation::Smi(), any_type, | 798 Representation::Smi(), any_type, |
| 808 Representation::Smi(), any_type); | 799 Representation::Smi(), any_type); |
| 809 } | 800 } |
| 810 | 801 |
| 811 | 802 |
| 812 TEST(GeneralizeRepresentationNoneToDouble) { | 803 TEST(GeneralizeRepresentationNoneToDouble) { |
| 813 CcTest::InitializeVM(); | 804 CcTest::InitializeVM(); |
| 814 v8::HandleScope scope(CcTest::isolate()); | 805 v8::HandleScope scope(CcTest::isolate()); |
| 815 Isolate* isolate = CcTest::i_isolate(); | 806 Isolate* isolate = CcTest::i_isolate(); |
| 816 Handle<HeapType> none_type = HeapType::None(isolate); | 807 Handle<FieldType> none_type = FieldType::None(isolate); |
| 817 Handle<HeapType> any_type = HeapType::Any(isolate); | 808 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 818 | 809 |
| 819 // None -> Double representation change is NOT trivial. | 810 // None -> Double representation change is NOT trivial. |
| 820 TestGeneralizeRepresentation(Representation::None(), none_type, | 811 TestGeneralizeRepresentation(Representation::None(), none_type, |
| 821 Representation::Double(), any_type, | 812 Representation::Double(), any_type, |
| 822 Representation::Double(), any_type); | 813 Representation::Double(), any_type); |
| 823 } | 814 } |
| 824 | 815 |
| 825 | 816 |
| 826 TEST(GeneralizeRepresentationNoneToHeapObject) { | 817 TEST(GeneralizeRepresentationNoneToHeapObject) { |
| 827 CcTest::InitializeVM(); | 818 CcTest::InitializeVM(); |
| 828 v8::HandleScope scope(CcTest::isolate()); | 819 v8::HandleScope scope(CcTest::isolate()); |
| 829 Isolate* isolate = CcTest::i_isolate(); | 820 Isolate* isolate = CcTest::i_isolate(); |
| 830 Handle<HeapType> none_type = HeapType::None(isolate); | 821 Handle<FieldType> none_type = FieldType::None(isolate); |
| 831 Handle<HeapType> value_type = | 822 Handle<FieldType> value_type = |
| 832 HeapType::Class(Map::Create(isolate, 0), isolate); | 823 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 833 | 824 |
| 834 // None -> HeapObject representation change is trivial. | 825 // None -> HeapObject representation change is trivial. |
| 835 TestGeneralizeRepresentationTrivial(Representation::None(), none_type, | 826 TestGeneralizeRepresentationTrivial(Representation::None(), none_type, |
| 836 Representation::HeapObject(), value_type, | 827 Representation::HeapObject(), value_type, |
| 837 Representation::HeapObject(), value_type); | 828 Representation::HeapObject(), value_type); |
| 838 } | 829 } |
| 839 | 830 |
| 840 | 831 |
| 841 TEST(GeneralizeRepresentationNoneToTagged) { | 832 TEST(GeneralizeRepresentationNoneToTagged) { |
| 842 CcTest::InitializeVM(); | 833 CcTest::InitializeVM(); |
| 843 v8::HandleScope scope(CcTest::isolate()); | 834 v8::HandleScope scope(CcTest::isolate()); |
| 844 Isolate* isolate = CcTest::i_isolate(); | 835 Isolate* isolate = CcTest::i_isolate(); |
| 845 Handle<HeapType> none_type = HeapType::None(isolate); | 836 Handle<FieldType> none_type = FieldType::None(isolate); |
| 846 Handle<HeapType> any_type = HeapType::Any(isolate); | 837 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 847 | 838 |
| 848 // None -> HeapObject representation change is trivial. | 839 // None -> HeapObject representation change is trivial. |
| 849 TestGeneralizeRepresentationTrivial(Representation::None(), none_type, | 840 TestGeneralizeRepresentationTrivial(Representation::None(), none_type, |
| 850 Representation::Tagged(), any_type, | 841 Representation::Tagged(), any_type, |
| 851 Representation::Tagged(), any_type); | 842 Representation::Tagged(), any_type); |
| 852 } | 843 } |
| 853 | 844 |
| 854 | 845 |
| 855 //////////////////////////////////////////////////////////////////////////////// | 846 //////////////////////////////////////////////////////////////////////////////// |
| 856 // A set of tests for representation generalization case with kAccessor | 847 // A set of tests for representation generalization case with kAccessor |
| 857 // properties. | 848 // properties. |
| 858 // | 849 // |
| 859 | 850 |
| 860 TEST(GeneralizeRepresentationWithAccessorProperties) { | 851 TEST(GeneralizeRepresentationWithAccessorProperties) { |
| 861 CcTest::InitializeVM(); | 852 CcTest::InitializeVM(); |
| 862 v8::HandleScope scope(CcTest::isolate()); | 853 v8::HandleScope scope(CcTest::isolate()); |
| 863 Isolate* isolate = CcTest::i_isolate(); | 854 Isolate* isolate = CcTest::i_isolate(); |
| 864 Handle<HeapType> any_type = HeapType::Any(isolate); | 855 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 865 Handle<AccessorPair> pair = CreateAccessorPair(true, true); | 856 Handle<AccessorPair> pair = CreateAccessorPair(true, true); |
| 866 | 857 |
| 867 const int kAccessorProp = kPropCount / 2; | 858 const int kAccessorProp = kPropCount / 2; |
| 868 Expectations expectations(isolate); | 859 Expectations expectations(isolate); |
| 869 | 860 |
| 870 // Create a map, add required properties to it and initialize expectations. | 861 // Create a map, add required properties to it and initialize expectations. |
| 871 Handle<Map> initial_map = Map::Create(isolate, 0); | 862 Handle<Map> initial_map = Map::Create(isolate, 0); |
| 872 Handle<Map> map = initial_map; | 863 Handle<Map> map = initial_map; |
| 873 for (int i = 0; i < kPropCount; i++) { | 864 for (int i = 0; i < kPropCount; i++) { |
| 874 if (i == kAccessorProp) { | 865 if (i == kAccessorProp) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 // This test ensures that representation/field type generalization is correctly | 916 // This test ensures that representation/field type generalization is correctly |
| 926 // propagated from one branch of transition tree (|map2|) to another (|map|). | 917 // propagated from one branch of transition tree (|map2|) to another (|map|). |
| 927 // | 918 // |
| 928 // + - p2B - p3 - p4: |map2| | 919 // + - p2B - p3 - p4: |map2| |
| 929 // | | 920 // | |
| 930 // {} - p0 - p1 - p2A - p3 - p4: |map| | 921 // {} - p0 - p1 - p2A - p3 - p4: |map| |
| 931 // | 922 // |
| 932 // where "p2A" and "p2B" differ only in the attributes. | 923 // where "p2A" and "p2B" differ only in the attributes. |
| 933 // | 924 // |
| 934 static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation( | 925 static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation( |
| 935 Representation from_representation, Handle<HeapType> from_type, | 926 Representation from_representation, Handle<FieldType> from_type, |
| 936 Representation to_representation, Handle<HeapType> to_type, | 927 Representation to_representation, Handle<FieldType> to_type, |
| 937 Representation expected_representation, Handle<HeapType> expected_type) { | 928 Representation expected_representation, Handle<FieldType> expected_type) { |
| 938 Isolate* isolate = CcTest::i_isolate(); | 929 Isolate* isolate = CcTest::i_isolate(); |
| 939 | 930 |
| 940 Expectations expectations(isolate); | 931 Expectations expectations(isolate); |
| 941 | 932 |
| 942 // Create a map, add required properties to it and initialize expectations. | 933 // Create a map, add required properties to it and initialize expectations. |
| 943 Handle<Map> initial_map = Map::Create(isolate, 0); | 934 Handle<Map> initial_map = Map::Create(isolate, 0); |
| 944 Handle<Map> map = initial_map; | 935 Handle<Map> map = initial_map; |
| 945 for (int i = 0; i < kPropCount; i++) { | 936 for (int i = 0; i < kPropCount; i++) { |
| 946 map = expectations.AddDataField(map, NONE, from_representation, from_type); | 937 map = expectations.AddDataField(map, NONE, from_representation, from_type); |
| 947 } | 938 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 // (from HeapObject to HeapObject) is correctly propagated from one branch of | 1000 // (from HeapObject to HeapObject) is correctly propagated from one branch of |
| 1010 // transition tree (|map2|) to another (|map|). | 1001 // transition tree (|map2|) to another (|map|). |
| 1011 // | 1002 // |
| 1012 // + - p2B - p3 - p4: |map2| | 1003 // + - p2B - p3 - p4: |map2| |
| 1013 // | | 1004 // | |
| 1014 // {} - p0 - p1 - p2A - p3 - p4: |map| | 1005 // {} - p0 - p1 - p2A - p3 - p4: |map| |
| 1015 // | 1006 // |
| 1016 // where "p2A" and "p2B" differ only in the attributes. | 1007 // where "p2A" and "p2B" differ only in the attributes. |
| 1017 // | 1008 // |
| 1018 static void TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( | 1009 static void TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( |
| 1019 Representation from_representation, Handle<HeapType> from_type, | 1010 Representation from_representation, Handle<FieldType> from_type, |
| 1020 Representation to_representation, Handle<HeapType> to_type, | 1011 Representation to_representation, Handle<FieldType> to_type, |
| 1021 Representation expected_representation, Handle<HeapType> expected_type, | 1012 Representation expected_representation, Handle<FieldType> expected_type, |
| 1022 bool expected_field_type_dependency = true) { | 1013 bool expected_field_type_dependency = true) { |
| 1023 Isolate* isolate = CcTest::i_isolate(); | 1014 Isolate* isolate = CcTest::i_isolate(); |
| 1024 | 1015 |
| 1025 Expectations expectations(isolate); | 1016 Expectations expectations(isolate); |
| 1026 | 1017 |
| 1027 // Create a map, add required properties to it and initialize expectations. | 1018 // Create a map, add required properties to it and initialize expectations. |
| 1028 Handle<Map> initial_map = Map::Create(isolate, 0); | 1019 Handle<Map> initial_map = Map::Create(isolate, 0); |
| 1029 Handle<Map> map = initial_map; | 1020 Handle<Map> map = initial_map; |
| 1030 for (int i = 0; i < kPropCount; i++) { | 1021 for (int i = 0; i < kPropCount; i++) { |
| 1031 map = expectations.AddDataField(map, NONE, from_representation, from_type); | 1022 map = expectations.AddDataField(map, NONE, from_representation, from_type); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 | 1080 |
| 1090 Handle<Map> updated_map = Map::Update(map); | 1081 Handle<Map> updated_map = Map::Update(map); |
| 1091 CHECK_EQ(*new_map, *updated_map); | 1082 CHECK_EQ(*new_map, *updated_map); |
| 1092 } | 1083 } |
| 1093 | 1084 |
| 1094 | 1085 |
| 1095 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToDouble) { | 1086 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToDouble) { |
| 1096 CcTest::InitializeVM(); | 1087 CcTest::InitializeVM(); |
| 1097 v8::HandleScope scope(CcTest::isolate()); | 1088 v8::HandleScope scope(CcTest::isolate()); |
| 1098 Isolate* isolate = CcTest::i_isolate(); | 1089 Isolate* isolate = CcTest::i_isolate(); |
| 1099 Handle<HeapType> any_type = HeapType::Any(isolate); | 1090 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1100 | 1091 |
| 1101 TestReconfigureDataFieldAttribute_GeneralizeRepresentation( | 1092 TestReconfigureDataFieldAttribute_GeneralizeRepresentation( |
| 1102 Representation::Smi(), any_type, Representation::Double(), any_type, | 1093 Representation::Smi(), any_type, Representation::Double(), any_type, |
| 1103 Representation::Double(), any_type); | 1094 Representation::Double(), any_type); |
| 1104 } | 1095 } |
| 1105 | 1096 |
| 1106 | 1097 |
| 1107 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToTagged) { | 1098 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToTagged) { |
| 1108 CcTest::InitializeVM(); | 1099 CcTest::InitializeVM(); |
| 1109 v8::HandleScope scope(CcTest::isolate()); | 1100 v8::HandleScope scope(CcTest::isolate()); |
| 1110 Isolate* isolate = CcTest::i_isolate(); | 1101 Isolate* isolate = CcTest::i_isolate(); |
| 1111 Handle<HeapType> any_type = HeapType::Any(isolate); | 1102 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1112 Handle<HeapType> value_type = | 1103 Handle<FieldType> value_type = |
| 1113 HeapType::Class(Map::Create(isolate, 0), isolate); | 1104 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1114 | 1105 |
| 1115 TestReconfigureDataFieldAttribute_GeneralizeRepresentation( | 1106 TestReconfigureDataFieldAttribute_GeneralizeRepresentation( |
| 1116 Representation::Smi(), any_type, Representation::HeapObject(), value_type, | 1107 Representation::Smi(), any_type, Representation::HeapObject(), value_type, |
| 1117 Representation::Tagged(), any_type); | 1108 Representation::Tagged(), any_type); |
| 1118 } | 1109 } |
| 1119 | 1110 |
| 1120 | 1111 |
| 1121 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationDoubleToTagged) { | 1112 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationDoubleToTagged) { |
| 1122 CcTest::InitializeVM(); | 1113 CcTest::InitializeVM(); |
| 1123 v8::HandleScope scope(CcTest::isolate()); | 1114 v8::HandleScope scope(CcTest::isolate()); |
| 1124 Isolate* isolate = CcTest::i_isolate(); | 1115 Isolate* isolate = CcTest::i_isolate(); |
| 1125 Handle<HeapType> any_type = HeapType::Any(isolate); | 1116 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1126 Handle<HeapType> value_type = | 1117 Handle<FieldType> value_type = |
| 1127 HeapType::Class(Map::Create(isolate, 0), isolate); | 1118 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1128 | 1119 |
| 1129 TestReconfigureDataFieldAttribute_GeneralizeRepresentation( | 1120 TestReconfigureDataFieldAttribute_GeneralizeRepresentation( |
| 1130 Representation::Double(), any_type, Representation::HeapObject(), | 1121 Representation::Double(), any_type, Representation::HeapObject(), |
| 1131 value_type, Representation::Tagged(), any_type); | 1122 value_type, Representation::Tagged(), any_type); |
| 1132 } | 1123 } |
| 1133 | 1124 |
| 1134 | 1125 |
| 1135 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjToHeapObj) { | 1126 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjToHeapObj) { |
| 1136 CcTest::InitializeVM(); | 1127 CcTest::InitializeVM(); |
| 1137 v8::HandleScope scope(CcTest::isolate()); | 1128 v8::HandleScope scope(CcTest::isolate()); |
| 1138 Isolate* isolate = CcTest::i_isolate(); | 1129 Isolate* isolate = CcTest::i_isolate(); |
| 1139 Handle<HeapType> any_type = HeapType::Any(isolate); | 1130 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1140 | 1131 |
| 1141 const int kMaxClassesPerFieldType = 1; | 1132 Handle<FieldType> current_type = |
| 1142 Handle<HeapType> current_type = | 1133 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1143 HeapType::Class(Map::Create(isolate, 0), isolate); | |
| 1144 | 1134 |
| 1145 for (int i = 0; i < kMaxClassesPerFieldType; i++) { | 1135 Handle<FieldType> new_type = |
| 1146 Handle<HeapType> new_type = | 1136 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1147 HeapType::Class(Map::Create(isolate, 0), isolate); | |
| 1148 | 1137 |
| 1149 Handle<HeapType> expected_type = | 1138 Handle<FieldType> expected_type = any_type; |
| 1150 (i < kMaxClassesPerFieldType - 1) | |
| 1151 ? HeapType::Union(current_type, new_type, isolate) | |
| 1152 : any_type; | |
| 1153 | 1139 |
| 1154 TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( | 1140 TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( |
| 1155 Representation::HeapObject(), current_type, | 1141 Representation::HeapObject(), current_type, Representation::HeapObject(), |
| 1156 Representation::HeapObject(), new_type, Representation::HeapObject(), | 1142 new_type, Representation::HeapObject(), expected_type); |
| 1157 expected_type); | 1143 current_type = expected_type; |
| 1158 current_type = expected_type; | |
| 1159 } | |
| 1160 | 1144 |
| 1161 Handle<HeapType> new_type = HeapType::Class(Map::Create(isolate, 0), isolate); | 1145 new_type = FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1162 | 1146 |
| 1163 TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( | 1147 TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( |
| 1164 Representation::HeapObject(), any_type, Representation::HeapObject(), | 1148 Representation::HeapObject(), any_type, Representation::HeapObject(), |
| 1165 new_type, Representation::HeapObject(), any_type, false); | 1149 new_type, Representation::HeapObject(), any_type, false); |
| 1166 } | 1150 } |
| 1167 | 1151 |
| 1168 | 1152 |
| 1169 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjectToTagged) { | 1153 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjectToTagged) { |
| 1170 CcTest::InitializeVM(); | 1154 CcTest::InitializeVM(); |
| 1171 v8::HandleScope scope(CcTest::isolate()); | 1155 v8::HandleScope scope(CcTest::isolate()); |
| 1172 Isolate* isolate = CcTest::i_isolate(); | 1156 Isolate* isolate = CcTest::i_isolate(); |
| 1173 Handle<HeapType> any_type = HeapType::Any(isolate); | 1157 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1174 Handle<HeapType> value_type = | 1158 Handle<FieldType> value_type = |
| 1175 HeapType::Class(Map::Create(isolate, 0), isolate); | 1159 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1176 | 1160 |
| 1177 TestReconfigureDataFieldAttribute_GeneralizeRepresentation( | 1161 TestReconfigureDataFieldAttribute_GeneralizeRepresentation( |
| 1178 Representation::HeapObject(), value_type, Representation::Smi(), any_type, | 1162 Representation::HeapObject(), value_type, Representation::Smi(), any_type, |
| 1179 Representation::Tagged(), any_type); | 1163 Representation::Tagged(), any_type); |
| 1180 } | 1164 } |
| 1181 | 1165 |
| 1182 | 1166 |
| 1183 // Checks that given |map| is deprecated and that it updates to given |new_map| | 1167 // Checks that given |map| is deprecated and that it updates to given |new_map| |
| 1184 // which in turn should match expectations. | 1168 // which in turn should match expectations. |
| 1185 struct CheckDeprecated { | 1169 struct CheckDeprecated { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 // + - p2A - p3 - p4: |map1| | 1245 // + - p2A - p3 - p4: |map1| |
| 1262 // | | 1246 // | |
| 1263 // + - the property customized by the TestConfig provided | 1247 // + - the property customized by the TestConfig provided |
| 1264 // | 1248 // |
| 1265 // where "p2A" and "p2B" differ only in the attributes. | 1249 // where "p2A" and "p2B" differ only in the attributes. |
| 1266 // | 1250 // |
| 1267 template <typename TestConfig, typename Checker> | 1251 template <typename TestConfig, typename Checker> |
| 1268 static void TestReconfigureProperty_CustomPropertyAfterTargetMap( | 1252 static void TestReconfigureProperty_CustomPropertyAfterTargetMap( |
| 1269 TestConfig& config, Checker& checker) { | 1253 TestConfig& config, Checker& checker) { |
| 1270 Isolate* isolate = CcTest::i_isolate(); | 1254 Isolate* isolate = CcTest::i_isolate(); |
| 1271 Handle<HeapType> any_type = HeapType::Any(isolate); | 1255 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1272 | 1256 |
| 1273 const int kCustomPropIndex = kPropCount - 2; | 1257 const int kCustomPropIndex = kPropCount - 2; |
| 1274 Expectations expectations(isolate); | 1258 Expectations expectations(isolate); |
| 1275 | 1259 |
| 1276 const int kSplitProp = 2; | 1260 const int kSplitProp = 2; |
| 1277 CHECK(kSplitProp < kCustomPropIndex); | 1261 CHECK(kSplitProp < kCustomPropIndex); |
| 1278 | 1262 |
| 1279 const Representation representation = Representation::Smi(); | 1263 const Representation representation = Representation::Smi(); |
| 1280 | 1264 |
| 1281 // Create common part of transition tree. | 1265 // Create common part of transition tree. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 | 1368 |
| 1385 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, | 1369 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, |
| 1386 Handle<Map> map) { | 1370 Handle<Map> map) { |
| 1387 CHECK(branch_id == 1 || branch_id == 2); | 1371 CHECK(branch_id == 1 || branch_id == 2); |
| 1388 Handle<JSFunction> js_func = branch_id == 1 ? js_func1_ : js_func2_; | 1372 Handle<JSFunction> js_func = branch_id == 1 ? js_func1_ : js_func2_; |
| 1389 return expectations.AddDataConstant(map, NONE, js_func); | 1373 return expectations.AddDataConstant(map, NONE, js_func); |
| 1390 } | 1374 } |
| 1391 | 1375 |
| 1392 void UpdateExpectations(int property_index, Expectations& expectations) { | 1376 void UpdateExpectations(int property_index, Expectations& expectations) { |
| 1393 Isolate* isolate = CcTest::i_isolate(); | 1377 Isolate* isolate = CcTest::i_isolate(); |
| 1394 Handle<HeapType> function_type = | 1378 Handle<FieldType> function_type = |
| 1395 HeapType::Class(isolate->sloppy_function_map(), isolate); | 1379 FieldType::Class(isolate->sloppy_function_map(), isolate); |
| 1396 expectations.SetDataField(property_index, Representation::HeapObject(), | 1380 expectations.SetDataField(property_index, Representation::HeapObject(), |
| 1397 function_type); | 1381 function_type); |
| 1398 } | 1382 } |
| 1399 }; | 1383 }; |
| 1400 | 1384 |
| 1401 TestConfig config; | 1385 TestConfig config; |
| 1402 // Two branches are "incompatible" so the |map1| should be deprecated. | 1386 // Two branches are "incompatible" so the |map1| should be deprecated. |
| 1403 CheckDeprecated checker; | 1387 CheckDeprecated checker; |
| 1404 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); | 1388 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
| 1405 } | 1389 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 Handle<AccessorPair> pair_; | 1500 Handle<AccessorPair> pair_; |
| 1517 TestConfig() { pair_ = CreateAccessorPair(true, true); } | 1501 TestConfig() { pair_ = CreateAccessorPair(true, true); } |
| 1518 | 1502 |
| 1519 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, | 1503 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, |
| 1520 Handle<Map> map) { | 1504 Handle<Map> map) { |
| 1521 CHECK(branch_id == 1 || branch_id == 2); | 1505 CHECK(branch_id == 1 || branch_id == 2); |
| 1522 if (branch_id == 1) { | 1506 if (branch_id == 1) { |
| 1523 return expectations.AddAccessorConstant(map, NONE, pair_); | 1507 return expectations.AddAccessorConstant(map, NONE, pair_); |
| 1524 } else { | 1508 } else { |
| 1525 Isolate* isolate = CcTest::i_isolate(); | 1509 Isolate* isolate = CcTest::i_isolate(); |
| 1526 Handle<HeapType> any_type = HeapType::Any(isolate); | 1510 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1527 return expectations.AddDataField(map, NONE, Representation::Smi(), | 1511 return expectations.AddDataField(map, NONE, Representation::Smi(), |
| 1528 any_type); | 1512 any_type); |
| 1529 } | 1513 } |
| 1530 } | 1514 } |
| 1531 | 1515 |
| 1532 void UpdateExpectations(int property_index, Expectations& expectations) {} | 1516 void UpdateExpectations(int property_index, Expectations& expectations) {} |
| 1533 }; | 1517 }; |
| 1534 | 1518 |
| 1535 TestConfig config; | 1519 TestConfig config; |
| 1536 // These are completely separate branches in transition tree. | 1520 // These are completely separate branches in transition tree. |
| 1537 CheckUnrelated checker; | 1521 CheckUnrelated checker; |
| 1538 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); | 1522 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
| 1539 } | 1523 } |
| 1540 | 1524 |
| 1541 | 1525 |
| 1542 //////////////////////////////////////////////////////////////////////////////// | 1526 //////////////////////////////////////////////////////////////////////////////// |
| 1543 // A set of tests checking split map deprecation. | 1527 // A set of tests checking split map deprecation. |
| 1544 // | 1528 // |
| 1545 | 1529 |
| 1546 TEST(ReconfigurePropertySplitMapTransitionsOverflow) { | 1530 TEST(ReconfigurePropertySplitMapTransitionsOverflow) { |
| 1547 CcTest::InitializeVM(); | 1531 CcTest::InitializeVM(); |
| 1548 v8::HandleScope scope(CcTest::isolate()); | 1532 v8::HandleScope scope(CcTest::isolate()); |
| 1549 Isolate* isolate = CcTest::i_isolate(); | 1533 Isolate* isolate = CcTest::i_isolate(); |
| 1550 Handle<HeapType> any_type = HeapType::Any(isolate); | 1534 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1551 | 1535 |
| 1552 Expectations expectations(isolate); | 1536 Expectations expectations(isolate); |
| 1553 | 1537 |
| 1554 // Create a map, add required properties to it and initialize expectations. | 1538 // Create a map, add required properties to it and initialize expectations. |
| 1555 Handle<Map> initial_map = Map::Create(isolate, 0); | 1539 Handle<Map> initial_map = Map::Create(isolate, 0); |
| 1556 Handle<Map> map = initial_map; | 1540 Handle<Map> map = initial_map; |
| 1557 for (int i = 0; i < kPropCount; i++) { | 1541 for (int i = 0; i < kPropCount; i++) { |
| 1558 map = expectations.AddDataField(map, NONE, Representation::Smi(), any_type); | 1542 map = expectations.AddDataField(map, NONE, Representation::Smi(), any_type); |
| 1559 } | 1543 } |
| 1560 CHECK(!map->is_deprecated()); | 1544 CHECK(!map->is_deprecated()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 // | 1615 // |
| 1632 // where "p4A" and "p4B" are exactly the same properties. | 1616 // where "p4A" and "p4B" are exactly the same properties. |
| 1633 // | 1617 // |
| 1634 // TODO(ishell): unify this test template with | 1618 // TODO(ishell): unify this test template with |
| 1635 // TestReconfigureDataFieldAttribute_GeneralizeRepresentation once | 1619 // TestReconfigureDataFieldAttribute_GeneralizeRepresentation once |
| 1636 // IS_PROTO_TRANS_ISSUE_FIXED and IS_NON_EQUIVALENT_TRANSITION_SUPPORTED are | 1620 // IS_PROTO_TRANS_ISSUE_FIXED and IS_NON_EQUIVALENT_TRANSITION_SUPPORTED are |
| 1637 // fixed. | 1621 // fixed. |
| 1638 template <typename TestConfig> | 1622 template <typename TestConfig> |
| 1639 static void TestGeneralizeRepresentationWithSpecialTransition( | 1623 static void TestGeneralizeRepresentationWithSpecialTransition( |
| 1640 TestConfig& config, Representation from_representation, | 1624 TestConfig& config, Representation from_representation, |
| 1641 Handle<HeapType> from_type, Representation to_representation, | 1625 Handle<FieldType> from_type, Representation to_representation, |
| 1642 Handle<HeapType> to_type, Representation expected_representation, | 1626 Handle<FieldType> to_type, Representation expected_representation, |
| 1643 Handle<HeapType> expected_type) { | 1627 Handle<FieldType> expected_type) { |
| 1644 Isolate* isolate = CcTest::i_isolate(); | 1628 Isolate* isolate = CcTest::i_isolate(); |
| 1645 | 1629 |
| 1646 Expectations expectations(isolate); | 1630 Expectations expectations(isolate); |
| 1647 | 1631 |
| 1648 // Create a map, add required properties to it and initialize expectations. | 1632 // Create a map, add required properties to it and initialize expectations. |
| 1649 Handle<Map> initial_map = Map::Create(isolate, 0); | 1633 Handle<Map> initial_map = Map::Create(isolate, 0); |
| 1650 Handle<Map> map = initial_map; | 1634 Handle<Map> map = initial_map; |
| 1651 for (int i = 0; i < kPropCount; i++) { | 1635 for (int i = 0; i < kPropCount; i++) { |
| 1652 map = expectations.AddDataField(map, NONE, from_representation, from_type); | 1636 map = expectations.AddDataField(map, NONE, from_representation, from_type); |
| 1653 } | 1637 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1723 updated_map = Map::Update(maps[i]); | 1707 updated_map = Map::Update(maps[i]); |
| 1724 CHECK_EQ(*active_map, *updated_map); | 1708 CHECK_EQ(*active_map, *updated_map); |
| 1725 } | 1709 } |
| 1726 } | 1710 } |
| 1727 | 1711 |
| 1728 | 1712 |
| 1729 TEST(ElementsKindTransitionFromMapOwningDescriptor) { | 1713 TEST(ElementsKindTransitionFromMapOwningDescriptor) { |
| 1730 CcTest::InitializeVM(); | 1714 CcTest::InitializeVM(); |
| 1731 v8::HandleScope scope(CcTest::isolate()); | 1715 v8::HandleScope scope(CcTest::isolate()); |
| 1732 Isolate* isolate = CcTest::i_isolate(); | 1716 Isolate* isolate = CcTest::i_isolate(); |
| 1733 Handle<HeapType> any_type = HeapType::Any(isolate); | 1717 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1734 Handle<HeapType> value_type = | 1718 Handle<FieldType> value_type = |
| 1735 HeapType::Class(Map::Create(isolate, 0), isolate); | 1719 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1736 | 1720 |
| 1737 struct TestConfig { | 1721 struct TestConfig { |
| 1738 Handle<Map> Transition(Handle<Map> map) { | 1722 Handle<Map> Transition(Handle<Map> map) { |
| 1739 return Map::CopyAsElementsKind(map, DICTIONARY_ELEMENTS, | 1723 return Map::CopyAsElementsKind(map, DICTIONARY_ELEMENTS, |
| 1740 INSERT_TRANSITION); | 1724 INSERT_TRANSITION); |
| 1741 } | 1725 } |
| 1742 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. | 1726 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. |
| 1743 bool generalizes_representations() const { return false; } | 1727 bool generalizes_representations() const { return false; } |
| 1744 bool is_non_equevalent_transition() const { return false; } | 1728 bool is_non_equevalent_transition() const { return false; } |
| 1745 }; | 1729 }; |
| 1746 TestConfig config; | 1730 TestConfig config; |
| 1747 TestGeneralizeRepresentationWithSpecialTransition( | 1731 TestGeneralizeRepresentationWithSpecialTransition( |
| 1748 config, Representation::Smi(), any_type, Representation::HeapObject(), | 1732 config, Representation::Smi(), any_type, Representation::HeapObject(), |
| 1749 value_type, Representation::Tagged(), any_type); | 1733 value_type, Representation::Tagged(), any_type); |
| 1750 } | 1734 } |
| 1751 | 1735 |
| 1752 | 1736 |
| 1753 TEST(ElementsKindTransitionFromMapNotOwningDescriptor) { | 1737 TEST(ElementsKindTransitionFromMapNotOwningDescriptor) { |
| 1754 CcTest::InitializeVM(); | 1738 CcTest::InitializeVM(); |
| 1755 v8::HandleScope scope(CcTest::isolate()); | 1739 v8::HandleScope scope(CcTest::isolate()); |
| 1756 Isolate* isolate = CcTest::i_isolate(); | 1740 Isolate* isolate = CcTest::i_isolate(); |
| 1757 Handle<HeapType> any_type = HeapType::Any(isolate); | 1741 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1758 Handle<HeapType> value_type = | 1742 Handle<FieldType> value_type = |
| 1759 HeapType::Class(Map::Create(isolate, 0), isolate); | 1743 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1760 | 1744 |
| 1761 struct TestConfig { | 1745 struct TestConfig { |
| 1762 Handle<Map> Transition(Handle<Map> map) { | 1746 Handle<Map> Transition(Handle<Map> map) { |
| 1763 Isolate* isolate = CcTest::i_isolate(); | 1747 Isolate* isolate = CcTest::i_isolate(); |
| 1764 Handle<HeapType> any_type = HeapType::Any(isolate); | 1748 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1765 | 1749 |
| 1766 // Add one more transition to |map| in order to prevent descriptors | 1750 // Add one more transition to |map| in order to prevent descriptors |
| 1767 // ownership. | 1751 // ownership. |
| 1768 CHECK(map->owns_descriptors()); | 1752 CHECK(map->owns_descriptors()); |
| 1769 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, | 1753 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, |
| 1770 Representation::Smi(), INSERT_TRANSITION) | 1754 Representation::Smi(), INSERT_TRANSITION) |
| 1771 .ToHandleChecked(); | 1755 .ToHandleChecked(); |
| 1772 CHECK(!map->owns_descriptors()); | 1756 CHECK(!map->owns_descriptors()); |
| 1773 | 1757 |
| 1774 return Map::CopyAsElementsKind(map, DICTIONARY_ELEMENTS, | 1758 return Map::CopyAsElementsKind(map, DICTIONARY_ELEMENTS, |
| 1775 INSERT_TRANSITION); | 1759 INSERT_TRANSITION); |
| 1776 } | 1760 } |
| 1777 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. | 1761 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. |
| 1778 bool generalizes_representations() const { return false; } | 1762 bool generalizes_representations() const { return false; } |
| 1779 bool is_non_equevalent_transition() const { return false; } | 1763 bool is_non_equevalent_transition() const { return false; } |
| 1780 }; | 1764 }; |
| 1781 TestConfig config; | 1765 TestConfig config; |
| 1782 TestGeneralizeRepresentationWithSpecialTransition( | 1766 TestGeneralizeRepresentationWithSpecialTransition( |
| 1783 config, Representation::Smi(), any_type, Representation::HeapObject(), | 1767 config, Representation::Smi(), any_type, Representation::HeapObject(), |
| 1784 value_type, Representation::Tagged(), any_type); | 1768 value_type, Representation::Tagged(), any_type); |
| 1785 } | 1769 } |
| 1786 | 1770 |
| 1787 | 1771 |
| 1788 TEST(ForObservedTransitionFromMapOwningDescriptor) { | 1772 TEST(ForObservedTransitionFromMapOwningDescriptor) { |
| 1789 CcTest::InitializeVM(); | 1773 CcTest::InitializeVM(); |
| 1790 v8::HandleScope scope(CcTest::isolate()); | 1774 v8::HandleScope scope(CcTest::isolate()); |
| 1791 Isolate* isolate = CcTest::i_isolate(); | 1775 Isolate* isolate = CcTest::i_isolate(); |
| 1792 Handle<HeapType> any_type = HeapType::Any(isolate); | 1776 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1793 Handle<HeapType> value_type = | 1777 Handle<FieldType> value_type = |
| 1794 HeapType::Class(Map::Create(isolate, 0), isolate); | 1778 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1795 | 1779 |
| 1796 struct TestConfig { | 1780 struct TestConfig { |
| 1797 Handle<Map> Transition(Handle<Map> map) { | 1781 Handle<Map> Transition(Handle<Map> map) { |
| 1798 return Map::CopyForObserved(map); | 1782 return Map::CopyForObserved(map); |
| 1799 } | 1783 } |
| 1800 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. | 1784 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. |
| 1801 bool generalizes_representations() const { return false; } | 1785 bool generalizes_representations() const { return false; } |
| 1802 bool is_non_equevalent_transition() const { return true; } | 1786 bool is_non_equevalent_transition() const { return true; } |
| 1803 }; | 1787 }; |
| 1804 TestConfig config; | 1788 TestConfig config; |
| 1805 TestGeneralizeRepresentationWithSpecialTransition( | 1789 TestGeneralizeRepresentationWithSpecialTransition( |
| 1806 config, Representation::Smi(), any_type, Representation::HeapObject(), | 1790 config, Representation::Smi(), any_type, Representation::HeapObject(), |
| 1807 value_type, Representation::Tagged(), any_type); | 1791 value_type, Representation::Tagged(), any_type); |
| 1808 } | 1792 } |
| 1809 | 1793 |
| 1810 | 1794 |
| 1811 TEST(ForObservedTransitionFromMapNotOwningDescriptor) { | 1795 TEST(ForObservedTransitionFromMapNotOwningDescriptor) { |
| 1812 CcTest::InitializeVM(); | 1796 CcTest::InitializeVM(); |
| 1813 v8::HandleScope scope(CcTest::isolate()); | 1797 v8::HandleScope scope(CcTest::isolate()); |
| 1814 Isolate* isolate = CcTest::i_isolate(); | 1798 Isolate* isolate = CcTest::i_isolate(); |
| 1815 Handle<HeapType> any_type = HeapType::Any(isolate); | 1799 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1816 Handle<HeapType> value_type = | 1800 Handle<FieldType> value_type = |
| 1817 HeapType::Class(Map::Create(isolate, 0), isolate); | 1801 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1818 | 1802 |
| 1819 struct TestConfig { | 1803 struct TestConfig { |
| 1820 Handle<Map> Transition(Handle<Map> map) { | 1804 Handle<Map> Transition(Handle<Map> map) { |
| 1821 Isolate* isolate = CcTest::i_isolate(); | 1805 Isolate* isolate = CcTest::i_isolate(); |
| 1822 Handle<HeapType> any_type = HeapType::Any(isolate); | 1806 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1823 | 1807 |
| 1824 // Add one more transition to |map| in order to prevent descriptors | 1808 // Add one more transition to |map| in order to prevent descriptors |
| 1825 // ownership. | 1809 // ownership. |
| 1826 CHECK(map->owns_descriptors()); | 1810 CHECK(map->owns_descriptors()); |
| 1827 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, | 1811 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, |
| 1828 Representation::Smi(), INSERT_TRANSITION) | 1812 Representation::Smi(), INSERT_TRANSITION) |
| 1829 .ToHandleChecked(); | 1813 .ToHandleChecked(); |
| 1830 CHECK(!map->owns_descriptors()); | 1814 CHECK(!map->owns_descriptors()); |
| 1831 | 1815 |
| 1832 return Map::CopyForObserved(map); | 1816 return Map::CopyForObserved(map); |
| 1833 } | 1817 } |
| 1834 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. | 1818 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. |
| 1835 bool generalizes_representations() const { return false; } | 1819 bool generalizes_representations() const { return false; } |
| 1836 bool is_non_equevalent_transition() const { return true; } | 1820 bool is_non_equevalent_transition() const { return true; } |
| 1837 }; | 1821 }; |
| 1838 TestConfig config; | 1822 TestConfig config; |
| 1839 TestGeneralizeRepresentationWithSpecialTransition( | 1823 TestGeneralizeRepresentationWithSpecialTransition( |
| 1840 config, Representation::Smi(), any_type, Representation::HeapObject(), | 1824 config, Representation::Smi(), any_type, Representation::HeapObject(), |
| 1841 value_type, Representation::Tagged(), any_type); | 1825 value_type, Representation::Tagged(), any_type); |
| 1842 } | 1826 } |
| 1843 | 1827 |
| 1844 | 1828 |
| 1845 TEST(PrototypeTransitionFromMapOwningDescriptor) { | 1829 TEST(PrototypeTransitionFromMapOwningDescriptor) { |
| 1846 CcTest::InitializeVM(); | 1830 CcTest::InitializeVM(); |
| 1847 v8::HandleScope scope(CcTest::isolate()); | 1831 v8::HandleScope scope(CcTest::isolate()); |
| 1848 Isolate* isolate = CcTest::i_isolate(); | 1832 Isolate* isolate = CcTest::i_isolate(); |
| 1849 | 1833 |
| 1850 Handle<HeapType> any_type = HeapType::Any(isolate); | 1834 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1851 Handle<HeapType> value_type = | 1835 Handle<FieldType> value_type = |
| 1852 HeapType::Class(Map::Create(isolate, 0), isolate); | 1836 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1853 | 1837 |
| 1854 struct TestConfig { | 1838 struct TestConfig { |
| 1855 Handle<JSObject> prototype_; | 1839 Handle<JSObject> prototype_; |
| 1856 | 1840 |
| 1857 TestConfig() { | 1841 TestConfig() { |
| 1858 Isolate* isolate = CcTest::i_isolate(); | 1842 Isolate* isolate = CcTest::i_isolate(); |
| 1859 Factory* factory = isolate->factory(); | 1843 Factory* factory = isolate->factory(); |
| 1860 prototype_ = factory->NewJSObjectFromMap(Map::Create(isolate, 0)); | 1844 prototype_ = factory->NewJSObjectFromMap(Map::Create(isolate, 0)); |
| 1861 } | 1845 } |
| 1862 | 1846 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1874 config, Representation::Smi(), any_type, Representation::HeapObject(), | 1858 config, Representation::Smi(), any_type, Representation::HeapObject(), |
| 1875 value_type, Representation::Tagged(), any_type); | 1859 value_type, Representation::Tagged(), any_type); |
| 1876 } | 1860 } |
| 1877 | 1861 |
| 1878 | 1862 |
| 1879 TEST(PrototypeTransitionFromMapNotOwningDescriptor) { | 1863 TEST(PrototypeTransitionFromMapNotOwningDescriptor) { |
| 1880 CcTest::InitializeVM(); | 1864 CcTest::InitializeVM(); |
| 1881 v8::HandleScope scope(CcTest::isolate()); | 1865 v8::HandleScope scope(CcTest::isolate()); |
| 1882 Isolate* isolate = CcTest::i_isolate(); | 1866 Isolate* isolate = CcTest::i_isolate(); |
| 1883 | 1867 |
| 1884 Handle<HeapType> any_type = HeapType::Any(isolate); | 1868 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1885 Handle<HeapType> value_type = | 1869 Handle<FieldType> value_type = |
| 1886 HeapType::Class(Map::Create(isolate, 0), isolate); | 1870 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1887 | 1871 |
| 1888 struct TestConfig { | 1872 struct TestConfig { |
| 1889 Handle<JSObject> prototype_; | 1873 Handle<JSObject> prototype_; |
| 1890 | 1874 |
| 1891 TestConfig() { | 1875 TestConfig() { |
| 1892 Isolate* isolate = CcTest::i_isolate(); | 1876 Isolate* isolate = CcTest::i_isolate(); |
| 1893 Factory* factory = isolate->factory(); | 1877 Factory* factory = isolate->factory(); |
| 1894 prototype_ = factory->NewJSObjectFromMap(Map::Create(isolate, 0)); | 1878 prototype_ = factory->NewJSObjectFromMap(Map::Create(isolate, 0)); |
| 1895 } | 1879 } |
| 1896 | 1880 |
| 1897 Handle<Map> Transition(Handle<Map> map) { | 1881 Handle<Map> Transition(Handle<Map> map) { |
| 1898 Isolate* isolate = CcTest::i_isolate(); | 1882 Isolate* isolate = CcTest::i_isolate(); |
| 1899 Handle<HeapType> any_type = HeapType::Any(isolate); | 1883 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1900 | 1884 |
| 1901 // Add one more transition to |map| in order to prevent descriptors | 1885 // Add one more transition to |map| in order to prevent descriptors |
| 1902 // ownership. | 1886 // ownership. |
| 1903 CHECK(map->owns_descriptors()); | 1887 CHECK(map->owns_descriptors()); |
| 1904 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, | 1888 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, |
| 1905 Representation::Smi(), INSERT_TRANSITION) | 1889 Representation::Smi(), INSERT_TRANSITION) |
| 1906 .ToHandleChecked(); | 1890 .ToHandleChecked(); |
| 1907 CHECK(!map->owns_descriptors()); | 1891 CHECK(!map->owns_descriptors()); |
| 1908 | 1892 |
| 1909 return Map::TransitionToPrototype(map, prototype_, REGULAR_PROTOTYPE); | 1893 return Map::TransitionToPrototype(map, prototype_, REGULAR_PROTOTYPE); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1921 } | 1905 } |
| 1922 | 1906 |
| 1923 | 1907 |
| 1924 //////////////////////////////////////////////////////////////////////////////// | 1908 //////////////////////////////////////////////////////////////////////////////// |
| 1925 // A set of tests for higher level transitioning mechanics. | 1909 // A set of tests for higher level transitioning mechanics. |
| 1926 // | 1910 // |
| 1927 | 1911 |
| 1928 struct TransitionToDataFieldOperator { | 1912 struct TransitionToDataFieldOperator { |
| 1929 Representation representation_; | 1913 Representation representation_; |
| 1930 PropertyAttributes attributes_; | 1914 PropertyAttributes attributes_; |
| 1931 Handle<HeapType> heap_type_; | 1915 Handle<FieldType> heap_type_; |
| 1932 Handle<Object> value_; | 1916 Handle<Object> value_; |
| 1933 | 1917 |
| 1934 TransitionToDataFieldOperator(Representation representation, | 1918 TransitionToDataFieldOperator(Representation representation, |
| 1935 Handle<HeapType> heap_type, | 1919 Handle<FieldType> heap_type, |
| 1936 Handle<Object> value, | 1920 Handle<Object> value, |
| 1937 PropertyAttributes attributes = NONE) | 1921 PropertyAttributes attributes = NONE) |
| 1938 : representation_(representation), | 1922 : representation_(representation), |
| 1939 attributes_(attributes), | 1923 attributes_(attributes), |
| 1940 heap_type_(heap_type), | 1924 heap_type_(heap_type), |
| 1941 value_(value) {} | 1925 value_(value) {} |
| 1942 | 1926 |
| 1943 Handle<Map> DoTransition(Expectations& expectations, Handle<Map> map) { | 1927 Handle<Map> DoTransition(Expectations& expectations, Handle<Map> map) { |
| 1944 return expectations.TransitionToDataField(map, attributes_, representation_, | 1928 return expectations.TransitionToDataField(map, attributes_, representation_, |
| 1945 heap_type_, value_); | 1929 heap_type_, value_); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1972 Handle<Map> DoTransition(Expectations& expectations, Handle<Map> map) { | 1956 Handle<Map> DoTransition(Expectations& expectations, Handle<Map> map) { |
| 1973 return expectations.TransitionToAccessorConstant(map, attributes_, pair_); | 1957 return expectations.TransitionToAccessorConstant(map, attributes_, pair_); |
| 1974 } | 1958 } |
| 1975 }; | 1959 }; |
| 1976 | 1960 |
| 1977 | 1961 |
| 1978 struct ReconfigureAsDataPropertyOperator { | 1962 struct ReconfigureAsDataPropertyOperator { |
| 1979 int descriptor_; | 1963 int descriptor_; |
| 1980 Representation representation_; | 1964 Representation representation_; |
| 1981 PropertyAttributes attributes_; | 1965 PropertyAttributes attributes_; |
| 1982 Handle<HeapType> heap_type_; | 1966 Handle<FieldType> heap_type_; |
| 1983 | 1967 |
| 1984 ReconfigureAsDataPropertyOperator(int descriptor, | 1968 ReconfigureAsDataPropertyOperator(int descriptor, |
| 1985 Representation representation, | 1969 Representation representation, |
| 1986 Handle<HeapType> heap_type, | 1970 Handle<FieldType> heap_type, |
| 1987 PropertyAttributes attributes = NONE) | 1971 PropertyAttributes attributes = NONE) |
| 1988 : descriptor_(descriptor), | 1972 : descriptor_(descriptor), |
| 1989 representation_(representation), | 1973 representation_(representation), |
| 1990 attributes_(attributes), | 1974 attributes_(attributes), |
| 1991 heap_type_(heap_type) {} | 1975 heap_type_(heap_type) {} |
| 1992 | 1976 |
| 1993 Handle<Map> DoTransition(Expectations& expectations, Handle<Map> map) { | 1977 Handle<Map> DoTransition(Expectations& expectations, Handle<Map> map) { |
| 1994 expectations.SetDataField(descriptor_, representation_, heap_type_); | 1978 expectations.SetDataField(descriptor_, representation_, heap_type_); |
| 1995 return Map::ReconfigureExistingProperty(map, descriptor_, kData, | 1979 return Map::ReconfigureExistingProperty(map, descriptor_, kData, |
| 1996 attributes_); | 1980 attributes_); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2012 attributes_); | 1996 attributes_); |
| 2013 } | 1997 } |
| 2014 }; | 1998 }; |
| 2015 | 1999 |
| 2016 | 2000 |
| 2017 // Checks that representation/field type generalization happened. | 2001 // Checks that representation/field type generalization happened. |
| 2018 struct FieldGeneralizationChecker { | 2002 struct FieldGeneralizationChecker { |
| 2019 int descriptor_; | 2003 int descriptor_; |
| 2020 Representation representation_; | 2004 Representation representation_; |
| 2021 PropertyAttributes attributes_; | 2005 PropertyAttributes attributes_; |
| 2022 Handle<HeapType> heap_type_; | 2006 Handle<FieldType> heap_type_; |
| 2023 | 2007 |
| 2024 FieldGeneralizationChecker(int descriptor, Representation representation, | 2008 FieldGeneralizationChecker(int descriptor, Representation representation, |
| 2025 Handle<HeapType> heap_type, | 2009 Handle<FieldType> heap_type, |
| 2026 PropertyAttributes attributes = NONE) | 2010 PropertyAttributes attributes = NONE) |
| 2027 : descriptor_(descriptor), | 2011 : descriptor_(descriptor), |
| 2028 representation_(representation), | 2012 representation_(representation), |
| 2029 attributes_(attributes), | 2013 attributes_(attributes), |
| 2030 heap_type_(heap_type) {} | 2014 heap_type_(heap_type) {} |
| 2031 | 2015 |
| 2032 void Check(Expectations& expectations2, Handle<Map> map1, Handle<Map> map2) { | 2016 void Check(Expectations& expectations2, Handle<Map> map1, Handle<Map> map2) { |
| 2033 CHECK(!map2->is_deprecated()); | 2017 CHECK(!map2->is_deprecated()); |
| 2034 | 2018 |
| 2035 CHECK(map1->is_deprecated()); | 2019 CHECK(map1->is_deprecated()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2078 // {} - p0 - p1 - pA - p3: |map| | 2062 // {} - p0 - p1 - pA - p3: |map| |
| 2079 // | | 2063 // | |
| 2080 // + - p4A: |map1| | 2064 // + - p4A: |map1| |
| 2081 // | 2065 // |
| 2082 // where "p4A" and "p4B" differ only in the attributes. | 2066 // where "p4A" and "p4B" differ only in the attributes. |
| 2083 // | 2067 // |
| 2084 template <typename TransitionOp1, typename TransitionOp2, typename Checker> | 2068 template <typename TransitionOp1, typename TransitionOp2, typename Checker> |
| 2085 static void TestTransitionTo(TransitionOp1& transition_op1, | 2069 static void TestTransitionTo(TransitionOp1& transition_op1, |
| 2086 TransitionOp2& transition_op2, Checker& checker) { | 2070 TransitionOp2& transition_op2, Checker& checker) { |
| 2087 Isolate* isolate = CcTest::i_isolate(); | 2071 Isolate* isolate = CcTest::i_isolate(); |
| 2088 Handle<HeapType> any_type = HeapType::Any(isolate); | 2072 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 2089 | 2073 |
| 2090 Expectations expectations(isolate); | 2074 Expectations expectations(isolate); |
| 2091 | 2075 |
| 2092 // Create a map, add required properties to it and initialize expectations. | 2076 // Create a map, add required properties to it and initialize expectations. |
| 2093 Handle<Map> initial_map = Map::Create(isolate, 0); | 2077 Handle<Map> initial_map = Map::Create(isolate, 0); |
| 2094 Handle<Map> map = initial_map; | 2078 Handle<Map> map = initial_map; |
| 2095 for (int i = 0; i < kPropCount - 1; i++) { | 2079 for (int i = 0; i < kPropCount - 1; i++) { |
| 2096 map = expectations.AddDataField(map, NONE, Representation::Smi(), any_type); | 2080 map = expectations.AddDataField(map, NONE, Representation::Smi(), any_type); |
| 2097 } | 2081 } |
| 2098 CHECK(expectations.Check(*map)); | 2082 CHECK(expectations.Check(*map)); |
| 2099 | 2083 |
| 2100 Expectations expectations1 = expectations; | 2084 Expectations expectations1 = expectations; |
| 2101 Handle<Map> map1 = transition_op1.DoTransition(expectations1, map); | 2085 Handle<Map> map1 = transition_op1.DoTransition(expectations1, map); |
| 2102 CHECK(expectations1.Check(*map1)); | 2086 CHECK(expectations1.Check(*map1)); |
| 2103 | 2087 |
| 2104 Expectations expectations2 = expectations; | 2088 Expectations expectations2 = expectations; |
| 2105 Handle<Map> map2 = transition_op2.DoTransition(expectations2, map); | 2089 Handle<Map> map2 = transition_op2.DoTransition(expectations2, map); |
| 2106 | 2090 |
| 2107 // Let the test customization do the check. | 2091 // Let the test customization do the check. |
| 2108 checker.Check(expectations2, map1, map2); | 2092 checker.Check(expectations2, map1, map2); |
| 2109 } | 2093 } |
| 2110 | 2094 |
| 2111 | 2095 |
| 2112 TEST(TransitionDataFieldToDataField) { | 2096 TEST(TransitionDataFieldToDataField) { |
| 2113 CcTest::InitializeVM(); | 2097 CcTest::InitializeVM(); |
| 2114 v8::HandleScope scope(CcTest::isolate()); | 2098 v8::HandleScope scope(CcTest::isolate()); |
| 2115 Isolate* isolate = CcTest::i_isolate(); | 2099 Isolate* isolate = CcTest::i_isolate(); |
| 2116 Handle<HeapType> any_type = HeapType::Any(isolate); | 2100 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 2117 | 2101 |
| 2118 Handle<Object> value1 = handle(Smi::FromInt(0), isolate); | 2102 Handle<Object> value1 = handle(Smi::FromInt(0), isolate); |
| 2119 TransitionToDataFieldOperator transition_op1(Representation::Smi(), any_type, | 2103 TransitionToDataFieldOperator transition_op1(Representation::Smi(), any_type, |
| 2120 value1); | 2104 value1); |
| 2121 | 2105 |
| 2122 Handle<Object> value2 = isolate->factory()->NewHeapNumber(0); | 2106 Handle<Object> value2 = isolate->factory()->NewHeapNumber(0); |
| 2123 TransitionToDataFieldOperator transition_op2(Representation::Double(), | 2107 TransitionToDataFieldOperator transition_op2(Representation::Double(), |
| 2124 any_type, value2); | 2108 any_type, value2); |
| 2125 | 2109 |
| 2126 FieldGeneralizationChecker checker(kPropCount - 1, Representation::Double(), | 2110 FieldGeneralizationChecker checker(kPropCount - 1, Representation::Double(), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2141 SameMapChecker checker; | 2125 SameMapChecker checker; |
| 2142 TestTransitionTo(transition_op, transition_op, checker); | 2126 TestTransitionTo(transition_op, transition_op, checker); |
| 2143 } | 2127 } |
| 2144 | 2128 |
| 2145 | 2129 |
| 2146 TEST(TransitionDataConstantToAnotherDataConstant) { | 2130 TEST(TransitionDataConstantToAnotherDataConstant) { |
| 2147 CcTest::InitializeVM(); | 2131 CcTest::InitializeVM(); |
| 2148 v8::HandleScope scope(CcTest::isolate()); | 2132 v8::HandleScope scope(CcTest::isolate()); |
| 2149 Isolate* isolate = CcTest::i_isolate(); | 2133 Isolate* isolate = CcTest::i_isolate(); |
| 2150 Factory* factory = isolate->factory(); | 2134 Factory* factory = isolate->factory(); |
| 2151 Handle<HeapType> function_type = | 2135 Handle<FieldType> function_type = |
| 2152 HeapType::Class(isolate->sloppy_function_map(), isolate); | 2136 FieldType::Class(isolate->sloppy_function_map(), isolate); |
| 2153 | 2137 |
| 2154 Handle<JSFunction> js_func1 = factory->NewFunction(factory->empty_string()); | 2138 Handle<JSFunction> js_func1 = factory->NewFunction(factory->empty_string()); |
| 2155 TransitionToDataConstantOperator transition_op1(js_func1); | 2139 TransitionToDataConstantOperator transition_op1(js_func1); |
| 2156 | 2140 |
| 2157 Handle<JSFunction> js_func2 = factory->NewFunction(factory->empty_string()); | 2141 Handle<JSFunction> js_func2 = factory->NewFunction(factory->empty_string()); |
| 2158 TransitionToDataConstantOperator transition_op2(js_func2); | 2142 TransitionToDataConstantOperator transition_op2(js_func2); |
| 2159 | 2143 |
| 2160 FieldGeneralizationChecker checker( | 2144 FieldGeneralizationChecker checker( |
| 2161 kPropCount - 1, Representation::HeapObject(), function_type); | 2145 kPropCount - 1, Representation::HeapObject(), function_type); |
| 2162 TestTransitionTo(transition_op1, transition_op2, checker); | 2146 TestTransitionTo(transition_op1, transition_op2, checker); |
| 2163 } | 2147 } |
| 2164 | 2148 |
| 2165 | 2149 |
| 2166 TEST(TransitionDataConstantToDataField) { | 2150 TEST(TransitionDataConstantToDataField) { |
| 2167 CcTest::InitializeVM(); | 2151 CcTest::InitializeVM(); |
| 2168 v8::HandleScope scope(CcTest::isolate()); | 2152 v8::HandleScope scope(CcTest::isolate()); |
| 2169 Isolate* isolate = CcTest::i_isolate(); | 2153 Isolate* isolate = CcTest::i_isolate(); |
| 2170 Factory* factory = isolate->factory(); | 2154 Factory* factory = isolate->factory(); |
| 2171 Handle<HeapType> any_type = HeapType::Any(isolate); | 2155 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 2172 | 2156 |
| 2173 Handle<JSFunction> js_func1 = factory->NewFunction(factory->empty_string()); | 2157 Handle<JSFunction> js_func1 = factory->NewFunction(factory->empty_string()); |
| 2174 TransitionToDataConstantOperator transition_op1(js_func1); | 2158 TransitionToDataConstantOperator transition_op1(js_func1); |
| 2175 | 2159 |
| 2176 Handle<Object> value2 = isolate->factory()->NewHeapNumber(0); | 2160 Handle<Object> value2 = isolate->factory()->NewHeapNumber(0); |
| 2177 TransitionToDataFieldOperator transition_op2(Representation::Double(), | 2161 TransitionToDataFieldOperator transition_op2(Representation::Double(), |
| 2178 any_type, value2); | 2162 any_type, value2); |
| 2179 | 2163 |
| 2180 FieldGeneralizationChecker checker(kPropCount - 1, Representation::Tagged(), | 2164 FieldGeneralizationChecker checker(kPropCount - 1, Representation::Tagged(), |
| 2181 any_type); | 2165 any_type); |
| 2182 TestTransitionTo(transition_op1, transition_op2, checker); | 2166 TestTransitionTo(transition_op1, transition_op2, checker); |
| 2183 } | 2167 } |
| 2184 | 2168 |
| 2185 | 2169 |
| 2186 TEST(TransitionAccessorConstantToSameAccessorConstant) { | 2170 TEST(TransitionAccessorConstantToSameAccessorConstant) { |
| 2187 CcTest::InitializeVM(); | 2171 CcTest::InitializeVM(); |
| 2188 v8::HandleScope scope(CcTest::isolate()); | 2172 v8::HandleScope scope(CcTest::isolate()); |
| 2189 | 2173 |
| 2190 Handle<AccessorPair> pair = CreateAccessorPair(true, true); | 2174 Handle<AccessorPair> pair = CreateAccessorPair(true, true); |
| 2191 TransitionToAccessorConstantOperator transition_op(pair); | 2175 TransitionToAccessorConstantOperator transition_op(pair); |
| 2192 | 2176 |
| 2193 SameMapChecker checker; | 2177 SameMapChecker checker; |
| 2194 TestTransitionTo(transition_op, transition_op, checker); | 2178 TestTransitionTo(transition_op, transition_op, checker); |
| 2195 } | 2179 } |
| 2196 | 2180 |
| 2197 | 2181 |
| 2198 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. | 2182 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. |
| 2199 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) | 2183 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) |
| OLD | NEW |