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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 Init(index, kAccessor, attrs, kConst, kDescriptor, Representation::Tagged(), | 168 Init(index, kAccessor, attrs, kConst, kDescriptor, Representation::Tagged(), |
169 FieldType::Any(isolate_)); | 169 FieldType::Any(isolate_)); |
170 } | 170 } |
171 | 171 |
172 void SetAccessorField(int index) { | 172 void SetAccessorField(int index) { |
173 SetAccessorField(index, attributes_[index]); | 173 SetAccessorField(index, attributes_[index]); |
174 } | 174 } |
175 | 175 |
176 void SetDataConstant(int index, PropertyAttributes attrs, | 176 void SetDataConstant(int index, PropertyAttributes attrs, |
177 Handle<JSFunction> value) { | 177 Handle<JSFunction> value) { |
178 Init(index, kData, attrs, kConst, kDescriptor, Representation::HeapObject(), | 178 if (FLAG_track_constant_fields) { |
179 value); | 179 Handle<FieldType> field_type(FieldType::Class(value->map()), isolate_); |
| 180 Init(index, kData, attrs, kConst, kField, Representation::HeapObject(), |
| 181 field_type); |
| 182 |
| 183 } else { |
| 184 Init(index, kData, attrs, kConst, kDescriptor, |
| 185 Representation::HeapObject(), value); |
| 186 } |
180 } | 187 } |
181 | 188 |
182 void SetDataConstant(int index, Handle<JSFunction> value) { | 189 void SetDataConstant(int index, Handle<JSFunction> value) { |
183 SetDataConstant(index, attributes_[index], value); | 190 SetDataConstant(index, attributes_[index], value); |
184 } | 191 } |
185 | 192 |
186 void SetAccessorConstant(int index, PropertyAttributes attrs, | 193 void SetAccessorConstant(int index, PropertyAttributes attrs, |
187 Handle<Object> getter, Handle<Object> setter) { | 194 Handle<Object> getter, Handle<Object> setter) { |
188 Init(index, kAccessor, attrs, kConst, kDescriptor, Representation::Tagged(), | 195 Init(index, kAccessor, attrs, kConst, kDescriptor, Representation::Tagged(), |
189 getter); | 196 getter); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 FieldType* type = descriptors->GetFieldType(descriptor); | 256 FieldType* type = descriptors->GetFieldType(descriptor); |
250 return FieldType::cast(expected_value) == type; | 257 return FieldType::cast(expected_value) == type; |
251 } else { | 258 } else { |
252 // kAccessor | 259 // kAccessor |
253 UNREACHABLE(); | 260 UNREACHABLE(); |
254 return false; | 261 return false; |
255 } | 262 } |
256 } else { | 263 } else { |
257 // kDescriptor | 264 // kDescriptor |
258 if (details.kind() == kData) { | 265 if (details.kind() == kData) { |
| 266 CHECK(!FLAG_track_constant_fields); |
259 return value == expected_value; | 267 return value == expected_value; |
260 } else { | 268 } else { |
261 // kAccessor | 269 // kAccessor |
262 if (value == expected_value) return true; | 270 if (value == expected_value) return true; |
263 if (!value->IsAccessorPair()) return false; | 271 if (!value->IsAccessorPair()) return false; |
264 AccessorPair* pair = AccessorPair::cast(value); | 272 AccessorPair* pair = AccessorPair::cast(value); |
265 return pair->Equals(expected_value, *setter_values_[descriptor]); | 273 return pair->Equals(expected_value, *setter_values_[descriptor]); |
266 } | 274 } |
267 } | 275 } |
268 UNREACHABLE(); | 276 UNREACHABLE(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 Handle<Map> AddDataField(Handle<Map> map, PropertyAttributes attributes, | 316 Handle<Map> AddDataField(Handle<Map> map, PropertyAttributes attributes, |
309 PropertyConstness constness, | 317 PropertyConstness constness, |
310 Representation representation, | 318 Representation representation, |
311 Handle<FieldType> heap_type) { | 319 Handle<FieldType> heap_type) { |
312 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 320 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
313 int property_index = number_of_properties_++; | 321 int property_index = number_of_properties_++; |
314 SetDataField(property_index, attributes, constness, representation, | 322 SetDataField(property_index, attributes, constness, representation, |
315 heap_type); | 323 heap_type); |
316 | 324 |
317 Handle<String> name = MakeName("prop", property_index); | 325 Handle<String> name = MakeName("prop", property_index); |
318 return Map::CopyWithField(map, name, heap_type, attributes, representation, | 326 return Map::CopyWithField(map, name, heap_type, attributes, constness, |
319 INSERT_TRANSITION) | 327 representation, INSERT_TRANSITION) |
320 .ToHandleChecked(); | 328 .ToHandleChecked(); |
321 } | 329 } |
322 | 330 |
323 Handle<Map> AddDataConstant(Handle<Map> map, PropertyAttributes attributes, | 331 Handle<Map> AddDataConstant(Handle<Map> map, PropertyAttributes attributes, |
324 Handle<JSFunction> value) { | 332 Handle<JSFunction> value) { |
325 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 333 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
326 int property_index = number_of_properties_++; | 334 int property_index = number_of_properties_++; |
327 SetDataConstant(property_index, attributes, value); | 335 SetDataConstant(property_index, attributes, value); |
328 | 336 |
329 Handle<String> name = MakeName("prop", property_index); | 337 Handle<String> name = MakeName("prop", property_index); |
330 return Map::CopyWithConstant(map, name, value, attributes, | 338 return Map::CopyWithConstant(map, name, value, attributes, |
331 INSERT_TRANSITION) | 339 INSERT_TRANSITION) |
332 .ToHandleChecked(); | 340 .ToHandleChecked(); |
333 } | 341 } |
334 | 342 |
335 Handle<Map> TransitionToDataField(Handle<Map> map, | 343 Handle<Map> TransitionToDataField(Handle<Map> map, |
336 PropertyAttributes attributes, | 344 PropertyAttributes attributes, |
337 PropertyConstness constness, | 345 PropertyConstness constness, |
338 Representation representation, | 346 Representation representation, |
339 Handle<FieldType> heap_type, | 347 Handle<FieldType> heap_type, |
340 Handle<Object> value) { | 348 Handle<Object> value) { |
341 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 349 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
342 int property_index = number_of_properties_++; | 350 int property_index = number_of_properties_++; |
343 SetDataField(property_index, attributes, constness, representation, | 351 SetDataField(property_index, attributes, constness, representation, |
344 heap_type); | 352 heap_type); |
345 | 353 |
346 Handle<String> name = MakeName("prop", property_index); | 354 Handle<String> name = MakeName("prop", property_index); |
347 return Map::TransitionToDataProperty( | 355 return Map::TransitionToDataProperty( |
348 map, name, value, attributes, Object::CERTAINLY_NOT_STORE_FROM_KEYED); | 356 map, name, value, attributes, constness, |
| 357 Object::CERTAINLY_NOT_STORE_FROM_KEYED); |
349 } | 358 } |
350 | 359 |
351 Handle<Map> TransitionToDataConstant(Handle<Map> map, | 360 Handle<Map> TransitionToDataConstant(Handle<Map> map, |
352 PropertyAttributes attributes, | 361 PropertyAttributes attributes, |
353 Handle<JSFunction> value) { | 362 Handle<JSFunction> value) { |
354 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 363 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
355 int property_index = number_of_properties_++; | 364 int property_index = number_of_properties_++; |
356 SetDataConstant(property_index, attributes, value); | 365 SetDataConstant(property_index, attributes, value); |
357 | 366 |
358 Handle<String> name = MakeName("prop", property_index); | 367 Handle<String> name = MakeName("prop", property_index); |
359 return Map::TransitionToDataProperty( | 368 return Map::TransitionToDataProperty( |
360 map, name, value, attributes, Object::CERTAINLY_NOT_STORE_FROM_KEYED); | 369 map, name, value, attributes, kConst, |
| 370 Object::CERTAINLY_NOT_STORE_FROM_KEYED); |
361 } | 371 } |
362 | 372 |
363 Handle<Map> FollowDataTransition(Handle<Map> map, | 373 Handle<Map> FollowDataTransition(Handle<Map> map, |
364 PropertyAttributes attributes, | 374 PropertyAttributes attributes, |
365 PropertyConstness constness, | 375 PropertyConstness constness, |
366 Representation representation, | 376 Representation representation, |
367 Handle<FieldType> heap_type) { | 377 Handle<FieldType> heap_type) { |
368 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); | 378 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); |
369 int property_index = number_of_properties_++; | 379 int property_index = number_of_properties_++; |
370 SetDataField(property_index, attributes, constness, representation, | 380 SetDataField(property_index, attributes, constness, representation, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 489 |
480 CHECK(!new_map->is_deprecated()); | 490 CHECK(!new_map->is_deprecated()); |
481 CHECK(new_map->is_stable()); | 491 CHECK(new_map->is_stable()); |
482 CHECK(expectations.Check(*new_map)); | 492 CHECK(expectations.Check(*new_map)); |
483 | 493 |
484 Handle<Map> new_map2 = Map::ReconfigureProperty( | 494 Handle<Map> new_map2 = Map::ReconfigureProperty( |
485 map, 0, kData, NONE, Representation::None(), none_type); | 495 map, 0, kData, NONE, Representation::None(), none_type); |
486 CHECK_EQ(*new_map, *new_map2); | 496 CHECK_EQ(*new_map, *new_map2); |
487 | 497 |
488 Handle<Object> value(Smi::kZero, isolate); | 498 Handle<Object> value(Smi::kZero, isolate); |
489 Handle<Map> prepared_map = Map::PrepareForDataProperty(new_map, 0, value); | 499 Handle<Map> prepared_map = |
| 500 Map::PrepareForDataProperty(new_map, 0, kConst, value); |
490 // None to Smi generalization is trivial, map does not change. | 501 // None to Smi generalization is trivial, map does not change. |
491 CHECK_EQ(*new_map, *prepared_map); | 502 CHECK_EQ(*new_map, *prepared_map); |
492 | 503 |
493 expectations.SetDataField(0, NONE, kMutable, Representation::Smi(), any_type); | 504 expectations.SetDataField(0, NONE, kMutable, Representation::Smi(), any_type); |
494 CHECK(prepared_map->is_stable()); | 505 CHECK(prepared_map->is_stable()); |
495 CHECK(expectations.Check(*prepared_map)); | 506 CHECK(expectations.Check(*prepared_map)); |
496 | 507 |
497 // Now create an object with |map|, migrate it to |prepared_map| and ensure | 508 // Now create an object with |map|, migrate it to |prepared_map| and ensure |
498 // that the data property is uninitialized. | 509 // that the data property is uninitialized. |
499 Factory* factory = isolate->factory(); | 510 Factory* factory = isolate->factory(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 | 600 |
590 // Create a map, add required properties to it and initialize expectations. | 601 // Create a map, add required properties to it and initialize expectations. |
591 Handle<Map> initial_map = Map::Create(isolate, 0); | 602 Handle<Map> initial_map = Map::Create(isolate, 0); |
592 Handle<Map> map = initial_map; | 603 Handle<Map> map = initial_map; |
593 Handle<Map> detach_point_map; | 604 Handle<Map> detach_point_map; |
594 for (int i = 0; i < kPropCount; i++) { | 605 for (int i = 0; i < kPropCount; i++) { |
595 if (i == property_index) { | 606 if (i == property_index) { |
596 map = expectations.AddDataField(map, NONE, from.constness, | 607 map = expectations.AddDataField(map, NONE, from.constness, |
597 from.representation, from.type); | 608 from.representation, from.type); |
598 } else { | 609 } else { |
599 map = expectations.AddDataField(map, NONE, kMutable, | 610 map = expectations.AddDataField(map, NONE, kDefaultFieldConstness, |
600 Representation::Smi(), any_type); | 611 Representation::Smi(), any_type); |
601 if (i == detach_property_at_index) { | 612 if (i == detach_property_at_index) { |
602 detach_point_map = map; | 613 detach_point_map = map; |
603 } | 614 } |
604 } | 615 } |
605 } | 616 } |
606 CHECK(!map->is_deprecated()); | 617 CHECK(!map->is_deprecated()); |
607 CHECK(map->is_stable()); | 618 CHECK(map->is_stable()); |
608 CHECK(expectations.Check(*map)); | 619 CHECK(expectations.Check(*map)); |
609 | 620 |
610 Zone zone(isolate->allocator(), ZONE_NAME); | 621 Zone zone(isolate->allocator(), ZONE_NAME); |
611 | 622 |
612 if (is_detached_map) { | 623 if (is_detached_map) { |
613 detach_point_map = Map::ReconfigureProperty( | 624 detach_point_map = Map::ReconfigureProperty( |
614 detach_point_map, detach_property_at_index, kData, NONE, | 625 detach_point_map, detach_property_at_index, kData, NONE, |
615 Representation::Tagged(), any_type); | 626 Representation::Tagged(), any_type); |
616 expectations.SetDataField(detach_property_at_index, kMutable, | 627 expectations.SetDataField(detach_property_at_index, kDefaultFieldConstness, |
617 Representation::Tagged(), any_type); | 628 Representation::Tagged(), any_type); |
618 CHECK(map->is_deprecated()); | 629 CHECK(map->is_deprecated()); |
619 CHECK(expectations.Check(*detach_point_map, | 630 CHECK(expectations.Check(*detach_point_map, |
620 detach_point_map->NumberOfOwnDescriptors())); | 631 detach_point_map->NumberOfOwnDescriptors())); |
621 } | 632 } |
622 | 633 |
623 // Create new maps by generalizing representation of propX field. | 634 // Create new maps by generalizing representation of propX field. |
624 Handle<Map> field_owner(map->FindFieldOwner(property_index), isolate); | 635 Handle<Map> field_owner(map->FindFieldOwner(property_index), isolate); |
625 CompilationDependencies dependencies(isolate, &zone); | 636 CompilationDependencies dependencies(isolate, &zone); |
626 CHECK(!dependencies.HasAborted()); | 637 CHECK(!dependencies.HasAborted()); |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 Handle<Map> updated_map = Map::Update(map); | 1105 Handle<Map> updated_map = Map::Update(map); |
1095 CHECK_EQ(*new_map, *updated_map); | 1106 CHECK_EQ(*new_map, *updated_map); |
1096 } | 1107 } |
1097 | 1108 |
1098 TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToDouble) { | 1109 TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToDouble) { |
1099 CcTest::InitializeVM(); | 1110 CcTest::InitializeVM(); |
1100 v8::HandleScope scope(CcTest::isolate()); | 1111 v8::HandleScope scope(CcTest::isolate()); |
1101 Isolate* isolate = CcTest::i_isolate(); | 1112 Isolate* isolate = CcTest::i_isolate(); |
1102 Handle<FieldType> any_type = FieldType::Any(isolate); | 1113 Handle<FieldType> any_type = FieldType::Any(isolate); |
1103 | 1114 |
| 1115 if (FLAG_track_constant_fields) { |
| 1116 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1117 {kConst, Representation::Smi(), any_type}, |
| 1118 {kConst, Representation::Double(), any_type}, |
| 1119 {kConst, Representation::Double(), any_type}); |
| 1120 |
| 1121 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1122 {kConst, Representation::Smi(), any_type}, |
| 1123 {kMutable, Representation::Double(), any_type}, |
| 1124 {kMutable, Representation::Double(), any_type}); |
| 1125 |
| 1126 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1127 {kMutable, Representation::Smi(), any_type}, |
| 1128 {kConst, Representation::Double(), any_type}, |
| 1129 {kMutable, Representation::Double(), any_type}); |
| 1130 } |
| 1131 |
1104 TestReconfigureDataFieldAttribute_GeneralizeField( | 1132 TestReconfigureDataFieldAttribute_GeneralizeField( |
1105 {kMutable, Representation::Smi(), any_type}, | 1133 {kMutable, Representation::Smi(), any_type}, |
1106 {kMutable, Representation::Double(), any_type}, | 1134 {kMutable, Representation::Double(), any_type}, |
1107 {kMutable, Representation::Double(), any_type}); | 1135 {kMutable, Representation::Double(), any_type}); |
1108 } | 1136 } |
1109 | 1137 |
1110 TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToTagged) { | 1138 TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToTagged) { |
1111 CcTest::InitializeVM(); | 1139 CcTest::InitializeVM(); |
1112 v8::HandleScope scope(CcTest::isolate()); | 1140 v8::HandleScope scope(CcTest::isolate()); |
1113 Isolate* isolate = CcTest::i_isolate(); | 1141 Isolate* isolate = CcTest::i_isolate(); |
1114 Handle<FieldType> any_type = FieldType::Any(isolate); | 1142 Handle<FieldType> any_type = FieldType::Any(isolate); |
1115 Handle<FieldType> value_type = | 1143 Handle<FieldType> value_type = |
1116 FieldType::Class(Map::Create(isolate, 0), isolate); | 1144 FieldType::Class(Map::Create(isolate, 0), isolate); |
1117 | 1145 |
| 1146 if (FLAG_track_constant_fields) { |
| 1147 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1148 {kConst, Representation::Smi(), any_type}, |
| 1149 {kConst, Representation::HeapObject(), value_type}, |
| 1150 {kConst, Representation::Tagged(), any_type}); |
| 1151 |
| 1152 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1153 {kConst, Representation::Smi(), any_type}, |
| 1154 {kMutable, Representation::HeapObject(), value_type}, |
| 1155 {kMutable, Representation::Tagged(), any_type}); |
| 1156 |
| 1157 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1158 {kMutable, Representation::Smi(), any_type}, |
| 1159 {kConst, Representation::HeapObject(), value_type}, |
| 1160 {kMutable, Representation::Tagged(), any_type}); |
| 1161 } |
| 1162 |
1118 TestReconfigureDataFieldAttribute_GeneralizeField( | 1163 TestReconfigureDataFieldAttribute_GeneralizeField( |
1119 {kMutable, Representation::Smi(), any_type}, | 1164 {kMutable, Representation::Smi(), any_type}, |
1120 {kMutable, Representation::HeapObject(), value_type}, | 1165 {kMutable, Representation::HeapObject(), value_type}, |
1121 {kMutable, Representation::Tagged(), any_type}); | 1166 {kMutable, Representation::Tagged(), any_type}); |
1122 } | 1167 } |
1123 | 1168 |
1124 TEST(ReconfigureDataFieldAttribute_GeneralizeDoubleFieldToTagged) { | 1169 TEST(ReconfigureDataFieldAttribute_GeneralizeDoubleFieldToTagged) { |
1125 CcTest::InitializeVM(); | 1170 CcTest::InitializeVM(); |
1126 v8::HandleScope scope(CcTest::isolate()); | 1171 v8::HandleScope scope(CcTest::isolate()); |
1127 Isolate* isolate = CcTest::i_isolate(); | 1172 Isolate* isolate = CcTest::i_isolate(); |
1128 Handle<FieldType> any_type = FieldType::Any(isolate); | 1173 Handle<FieldType> any_type = FieldType::Any(isolate); |
1129 Handle<FieldType> value_type = | 1174 Handle<FieldType> value_type = |
1130 FieldType::Class(Map::Create(isolate, 0), isolate); | 1175 FieldType::Class(Map::Create(isolate, 0), isolate); |
1131 | 1176 |
| 1177 if (FLAG_track_constant_fields) { |
| 1178 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1179 {kConst, Representation::Double(), any_type}, |
| 1180 {kConst, Representation::HeapObject(), value_type}, |
| 1181 {kConst, Representation::Tagged(), any_type}); |
| 1182 |
| 1183 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1184 {kConst, Representation::Double(), any_type}, |
| 1185 {kMutable, Representation::HeapObject(), value_type}, |
| 1186 {kMutable, Representation::Tagged(), any_type}); |
| 1187 |
| 1188 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1189 {kMutable, Representation::Double(), any_type}, |
| 1190 {kConst, Representation::HeapObject(), value_type}, |
| 1191 {kMutable, Representation::Tagged(), any_type}); |
| 1192 } |
| 1193 |
1132 TestReconfigureDataFieldAttribute_GeneralizeField( | 1194 TestReconfigureDataFieldAttribute_GeneralizeField( |
1133 {kMutable, Representation::Double(), any_type}, | 1195 {kMutable, Representation::Double(), any_type}, |
1134 {kMutable, Representation::HeapObject(), value_type}, | 1196 {kMutable, Representation::HeapObject(), value_type}, |
1135 {kMutable, Representation::Tagged(), any_type}); | 1197 {kMutable, Representation::Tagged(), any_type}); |
1136 } | 1198 } |
1137 | 1199 |
1138 TEST(ReconfigureDataFieldAttribute_GeneralizeHeapObjFieldToHeapObj) { | 1200 TEST(ReconfigureDataFieldAttribute_GeneralizeHeapObjFieldToHeapObj) { |
1139 CcTest::InitializeVM(); | 1201 CcTest::InitializeVM(); |
1140 v8::HandleScope scope(CcTest::isolate()); | 1202 v8::HandleScope scope(CcTest::isolate()); |
1141 Isolate* isolate = CcTest::i_isolate(); | 1203 Isolate* isolate = CcTest::i_isolate(); |
1142 Handle<FieldType> any_type = FieldType::Any(isolate); | 1204 Handle<FieldType> any_type = FieldType::Any(isolate); |
1143 | 1205 |
1144 Handle<FieldType> current_type = | 1206 Handle<FieldType> current_type = |
1145 FieldType::Class(Map::Create(isolate, 0), isolate); | 1207 FieldType::Class(Map::Create(isolate, 0), isolate); |
1146 | 1208 |
1147 Handle<FieldType> new_type = | 1209 Handle<FieldType> new_type = |
1148 FieldType::Class(Map::Create(isolate, 0), isolate); | 1210 FieldType::Class(Map::Create(isolate, 0), isolate); |
1149 | 1211 |
1150 Handle<FieldType> expected_type = any_type; | 1212 Handle<FieldType> expected_type = any_type; |
1151 | 1213 |
| 1214 // Check generalizations that trigger deopts. |
| 1215 if (FLAG_track_constant_fields) { |
| 1216 TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( |
| 1217 {kConst, Representation::HeapObject(), current_type}, |
| 1218 {kConst, Representation::HeapObject(), new_type}, |
| 1219 {kConst, Representation::HeapObject(), expected_type}); |
| 1220 |
| 1221 // Currently, kConst to kMutable migration causes map change, therefore |
| 1222 // non-trivial generalization. |
| 1223 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1224 {kConst, Representation::HeapObject(), current_type}, |
| 1225 {kMutable, Representation::HeapObject(), new_type}, |
| 1226 {kMutable, Representation::HeapObject(), expected_type}); |
| 1227 |
| 1228 TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( |
| 1229 {kMutable, Representation::HeapObject(), current_type}, |
| 1230 {kConst, Representation::HeapObject(), new_type}, |
| 1231 {kMutable, Representation::HeapObject(), expected_type}); |
| 1232 } |
1152 TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( | 1233 TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( |
1153 {kMutable, Representation::HeapObject(), current_type}, | 1234 {kMutable, Representation::HeapObject(), current_type}, |
1154 {kMutable, Representation::HeapObject(), new_type}, | 1235 {kMutable, Representation::HeapObject(), new_type}, |
1155 {kMutable, Representation::HeapObject(), expected_type}); | 1236 {kMutable, Representation::HeapObject(), expected_type}); |
1156 current_type = expected_type; | 1237 current_type = expected_type; |
1157 | 1238 |
| 1239 // Check generalizations that do not trigger deopts. |
1158 new_type = FieldType::Class(Map::Create(isolate, 0), isolate); | 1240 new_type = FieldType::Class(Map::Create(isolate, 0), isolate); |
1159 | 1241 |
| 1242 if (FLAG_track_constant_fields) { |
| 1243 TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( |
| 1244 {kConst, Representation::HeapObject(), any_type}, |
| 1245 {kConst, Representation::HeapObject(), new_type}, |
| 1246 {kConst, Representation::HeapObject(), any_type}, false); |
| 1247 |
| 1248 // Currently, kConst to kMutable migration causes map change, therefore |
| 1249 // non-trivial generalization. |
| 1250 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1251 {kConst, Representation::HeapObject(), any_type}, |
| 1252 {kMutable, Representation::HeapObject(), new_type}, |
| 1253 {kMutable, Representation::HeapObject(), any_type}); |
| 1254 |
| 1255 TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( |
| 1256 {kMutable, Representation::HeapObject(), any_type}, |
| 1257 {kConst, Representation::HeapObject(), new_type}, |
| 1258 {kMutable, Representation::HeapObject(), any_type}, false); |
| 1259 } |
1160 TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( | 1260 TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( |
1161 {kMutable, Representation::HeapObject(), any_type}, | 1261 {kMutable, Representation::HeapObject(), any_type}, |
1162 {kMutable, Representation::HeapObject(), new_type}, | 1262 {kMutable, Representation::HeapObject(), new_type}, |
1163 {kMutable, Representation::HeapObject(), any_type}, false); | 1263 {kMutable, Representation::HeapObject(), any_type}, false); |
1164 } | 1264 } |
1165 | 1265 |
1166 TEST(ReconfigureDataFieldAttribute_GeneralizeHeapObjectFieldToTagged) { | 1266 TEST(ReconfigureDataFieldAttribute_GeneralizeHeapObjectFieldToTagged) { |
1167 CcTest::InitializeVM(); | 1267 CcTest::InitializeVM(); |
1168 v8::HandleScope scope(CcTest::isolate()); | 1268 v8::HandleScope scope(CcTest::isolate()); |
1169 Isolate* isolate = CcTest::i_isolate(); | 1269 Isolate* isolate = CcTest::i_isolate(); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 } | 1499 } |
1400 | 1500 |
1401 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, | 1501 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, |
1402 Handle<Map> map) { | 1502 Handle<Map> map) { |
1403 CHECK(branch_id == 1 || branch_id == 2); | 1503 CHECK(branch_id == 1 || branch_id == 2); |
1404 Handle<JSFunction> js_func = branch_id == 1 ? js_func1_ : js_func2_; | 1504 Handle<JSFunction> js_func = branch_id == 1 ? js_func1_ : js_func2_; |
1405 return expectations.AddDataConstant(map, NONE, js_func); | 1505 return expectations.AddDataConstant(map, NONE, js_func); |
1406 } | 1506 } |
1407 | 1507 |
1408 void UpdateExpectations(int property_index, Expectations& expectations) { | 1508 void UpdateExpectations(int property_index, Expectations& expectations) { |
1409 expectations.SetDataField(property_index, kMutable, | 1509 PropertyConstness expected_constness = |
| 1510 FLAG_track_constant_fields ? kConst : kMutable; |
| 1511 expectations.SetDataField(property_index, expected_constness, |
1410 Representation::HeapObject(), function_type_); | 1512 Representation::HeapObject(), function_type_); |
1411 } | 1513 } |
1412 }; | 1514 }; |
1413 | 1515 |
1414 TestConfig config; | 1516 TestConfig config; |
1415 // Two branches are "incompatible" so the |map1| should be deprecated. | 1517 if (FLAG_track_constant_fields) { |
1416 CheckDeprecated checker; | 1518 CheckSameMap checker; |
1417 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); | 1519 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
| 1520 |
| 1521 } else { |
| 1522 // Two branches are "incompatible" so the |map1| should be deprecated. |
| 1523 CheckDeprecated checker; |
| 1524 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
| 1525 } |
1418 } | 1526 } |
1419 | 1527 |
1420 | 1528 |
1421 TEST(ReconfigureDataFieldAttribute_DataConstantToAccConstantAfterTargetMap) { | 1529 TEST(ReconfigureDataFieldAttribute_DataConstantToAccConstantAfterTargetMap) { |
1422 CcTest::InitializeVM(); | 1530 CcTest::InitializeVM(); |
1423 v8::HandleScope scope(CcTest::isolate()); | 1531 v8::HandleScope scope(CcTest::isolate()); |
1424 | 1532 |
1425 struct TestConfig { | 1533 struct TestConfig { |
1426 Handle<JSFunction> js_func_; | 1534 Handle<JSFunction> js_func_; |
1427 Handle<AccessorPair> pair_; | 1535 Handle<AccessorPair> pair_; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 TestConfig() { pair_ = CreateAccessorPair(true, true); } | 1638 TestConfig() { pair_ = CreateAccessorPair(true, true); } |
1531 | 1639 |
1532 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, | 1640 Handle<Map> AddPropertyAtBranch(int branch_id, Expectations& expectations, |
1533 Handle<Map> map) { | 1641 Handle<Map> map) { |
1534 CHECK(branch_id == 1 || branch_id == 2); | 1642 CHECK(branch_id == 1 || branch_id == 2); |
1535 if (branch_id == 1) { | 1643 if (branch_id == 1) { |
1536 return expectations.AddAccessorConstant(map, NONE, pair_); | 1644 return expectations.AddAccessorConstant(map, NONE, pair_); |
1537 } else { | 1645 } else { |
1538 Isolate* isolate = CcTest::i_isolate(); | 1646 Isolate* isolate = CcTest::i_isolate(); |
1539 Handle<FieldType> any_type = FieldType::Any(isolate); | 1647 Handle<FieldType> any_type = FieldType::Any(isolate); |
1540 return expectations.AddDataField(map, NONE, kMutable, | 1648 return expectations.AddDataField(map, NONE, kDefaultFieldConstness, |
1541 Representation::Smi(), any_type); | 1649 Representation::Smi(), any_type); |
1542 } | 1650 } |
1543 } | 1651 } |
1544 | 1652 |
1545 void UpdateExpectations(int property_index, Expectations& expectations) {} | 1653 void UpdateExpectations(int property_index, Expectations& expectations) {} |
1546 }; | 1654 }; |
1547 | 1655 |
1548 TestConfig config; | 1656 TestConfig config; |
1549 // These are completely separate branches in transition tree. | 1657 // These are completely separate branches in transition tree. |
1550 CheckUnrelated checker; | 1658 CheckUnrelated checker; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1742 CHECK_EQ(*updated_map, transitioned_map); | 1850 CHECK_EQ(*updated_map, transitioned_map); |
1743 } | 1851 } |
1744 } | 1852 } |
1745 | 1853 |
1746 TEST(ReconfigureElementsKind_GeneralizeSmiFieldToDouble) { | 1854 TEST(ReconfigureElementsKind_GeneralizeSmiFieldToDouble) { |
1747 CcTest::InitializeVM(); | 1855 CcTest::InitializeVM(); |
1748 v8::HandleScope scope(CcTest::isolate()); | 1856 v8::HandleScope scope(CcTest::isolate()); |
1749 Isolate* isolate = CcTest::i_isolate(); | 1857 Isolate* isolate = CcTest::i_isolate(); |
1750 Handle<FieldType> any_type = FieldType::Any(isolate); | 1858 Handle<FieldType> any_type = FieldType::Any(isolate); |
1751 | 1859 |
| 1860 if (FLAG_track_constant_fields) { |
| 1861 TestReconfigureElementsKind_GeneralizeField( |
| 1862 {kConst, Representation::Smi(), any_type}, |
| 1863 {kConst, Representation::Double(), any_type}, |
| 1864 {kConst, Representation::Double(), any_type}); |
| 1865 |
| 1866 TestReconfigureElementsKind_GeneralizeField( |
| 1867 {kConst, Representation::Smi(), any_type}, |
| 1868 {kMutable, Representation::Double(), any_type}, |
| 1869 {kMutable, Representation::Double(), any_type}); |
| 1870 |
| 1871 TestReconfigureElementsKind_GeneralizeField( |
| 1872 {kMutable, Representation::Smi(), any_type}, |
| 1873 {kConst, Representation::Double(), any_type}, |
| 1874 {kMutable, Representation::Double(), any_type}); |
| 1875 } |
1752 TestReconfigureElementsKind_GeneralizeField( | 1876 TestReconfigureElementsKind_GeneralizeField( |
1753 {kMutable, Representation::Smi(), any_type}, | 1877 {kMutable, Representation::Smi(), any_type}, |
1754 {kMutable, Representation::Double(), any_type}, | 1878 {kMutable, Representation::Double(), any_type}, |
1755 {kMutable, Representation::Double(), any_type}); | 1879 {kMutable, Representation::Double(), any_type}); |
1756 } | 1880 } |
1757 | 1881 |
1758 TEST(ReconfigureElementsKind_GeneralizeSmiFieldToTagged) { | 1882 TEST(ReconfigureElementsKind_GeneralizeSmiFieldToTagged) { |
1759 CcTest::InitializeVM(); | 1883 CcTest::InitializeVM(); |
1760 v8::HandleScope scope(CcTest::isolate()); | 1884 v8::HandleScope scope(CcTest::isolate()); |
1761 Isolate* isolate = CcTest::i_isolate(); | 1885 Isolate* isolate = CcTest::i_isolate(); |
1762 Handle<FieldType> any_type = FieldType::Any(isolate); | 1886 Handle<FieldType> any_type = FieldType::Any(isolate); |
1763 Handle<FieldType> value_type = | 1887 Handle<FieldType> value_type = |
1764 FieldType::Class(Map::Create(isolate, 0), isolate); | 1888 FieldType::Class(Map::Create(isolate, 0), isolate); |
1765 | 1889 |
| 1890 if (FLAG_track_constant_fields) { |
| 1891 TestReconfigureElementsKind_GeneralizeField( |
| 1892 {kConst, Representation::Smi(), any_type}, |
| 1893 {kConst, Representation::HeapObject(), value_type}, |
| 1894 {kConst, Representation::Tagged(), any_type}); |
| 1895 |
| 1896 TestReconfigureElementsKind_GeneralizeField( |
| 1897 {kConst, Representation::Smi(), any_type}, |
| 1898 {kMutable, Representation::HeapObject(), value_type}, |
| 1899 {kMutable, Representation::Tagged(), any_type}); |
| 1900 |
| 1901 TestReconfigureElementsKind_GeneralizeField( |
| 1902 {kMutable, Representation::Smi(), any_type}, |
| 1903 {kConst, Representation::HeapObject(), value_type}, |
| 1904 {kMutable, Representation::Tagged(), any_type}); |
| 1905 } |
1766 TestReconfigureElementsKind_GeneralizeField( | 1906 TestReconfigureElementsKind_GeneralizeField( |
1767 {kMutable, Representation::Smi(), any_type}, | 1907 {kMutable, Representation::Smi(), any_type}, |
1768 {kMutable, Representation::HeapObject(), value_type}, | 1908 {kMutable, Representation::HeapObject(), value_type}, |
1769 {kMutable, Representation::Tagged(), any_type}); | 1909 {kMutable, Representation::Tagged(), any_type}); |
1770 } | 1910 } |
1771 | 1911 |
1772 TEST(ReconfigureElementsKind_GeneralizeDoubleFieldToTagged) { | 1912 TEST(ReconfigureElementsKind_GeneralizeDoubleFieldToTagged) { |
1773 CcTest::InitializeVM(); | 1913 CcTest::InitializeVM(); |
1774 v8::HandleScope scope(CcTest::isolate()); | 1914 v8::HandleScope scope(CcTest::isolate()); |
1775 Isolate* isolate = CcTest::i_isolate(); | 1915 Isolate* isolate = CcTest::i_isolate(); |
1776 Handle<FieldType> any_type = FieldType::Any(isolate); | 1916 Handle<FieldType> any_type = FieldType::Any(isolate); |
1777 Handle<FieldType> value_type = | 1917 Handle<FieldType> value_type = |
1778 FieldType::Class(Map::Create(isolate, 0), isolate); | 1918 FieldType::Class(Map::Create(isolate, 0), isolate); |
1779 | 1919 |
| 1920 if (FLAG_track_constant_fields) { |
| 1921 TestReconfigureElementsKind_GeneralizeField( |
| 1922 {kConst, Representation::Double(), any_type}, |
| 1923 {kConst, Representation::HeapObject(), value_type}, |
| 1924 {kConst, Representation::Tagged(), any_type}); |
| 1925 |
| 1926 TestReconfigureElementsKind_GeneralizeField( |
| 1927 {kConst, Representation::Double(), any_type}, |
| 1928 {kMutable, Representation::HeapObject(), value_type}, |
| 1929 {kMutable, Representation::Tagged(), any_type}); |
| 1930 |
| 1931 TestReconfigureElementsKind_GeneralizeField( |
| 1932 {kMutable, Representation::Double(), any_type}, |
| 1933 {kConst, Representation::HeapObject(), value_type}, |
| 1934 {kMutable, Representation::Tagged(), any_type}); |
| 1935 } |
1780 TestReconfigureElementsKind_GeneralizeField( | 1936 TestReconfigureElementsKind_GeneralizeField( |
1781 {kMutable, Representation::Double(), any_type}, | 1937 {kMutable, Representation::Double(), any_type}, |
1782 {kMutable, Representation::HeapObject(), value_type}, | 1938 {kMutable, Representation::HeapObject(), value_type}, |
1783 {kMutable, Representation::Tagged(), any_type}); | 1939 {kMutable, Representation::Tagged(), any_type}); |
1784 } | 1940 } |
1785 | 1941 |
1786 TEST(ReconfigureElementsKind_GeneralizeHeapObjFieldToHeapObj) { | 1942 TEST(ReconfigureElementsKind_GeneralizeHeapObjFieldToHeapObj) { |
1787 CcTest::InitializeVM(); | 1943 CcTest::InitializeVM(); |
1788 v8::HandleScope scope(CcTest::isolate()); | 1944 v8::HandleScope scope(CcTest::isolate()); |
1789 Isolate* isolate = CcTest::i_isolate(); | 1945 Isolate* isolate = CcTest::i_isolate(); |
1790 Handle<FieldType> any_type = FieldType::Any(isolate); | 1946 Handle<FieldType> any_type = FieldType::Any(isolate); |
1791 | 1947 |
1792 Handle<FieldType> current_type = | 1948 Handle<FieldType> current_type = |
1793 FieldType::Class(Map::Create(isolate, 0), isolate); | 1949 FieldType::Class(Map::Create(isolate, 0), isolate); |
1794 | 1950 |
1795 Handle<FieldType> new_type = | 1951 Handle<FieldType> new_type = |
1796 FieldType::Class(Map::Create(isolate, 0), isolate); | 1952 FieldType::Class(Map::Create(isolate, 0), isolate); |
1797 | 1953 |
1798 Handle<FieldType> expected_type = any_type; | 1954 Handle<FieldType> expected_type = any_type; |
1799 | 1955 |
| 1956 // Check generalizations that trigger deopts. |
| 1957 if (FLAG_track_constant_fields) { |
| 1958 TestReconfigureElementsKind_GeneralizeFieldTrivial( |
| 1959 {kConst, Representation::HeapObject(), current_type}, |
| 1960 {kConst, Representation::HeapObject(), new_type}, |
| 1961 {kConst, Representation::HeapObject(), expected_type}); |
| 1962 |
| 1963 // Currently, kConst to kMutable migration causes map change, therefore |
| 1964 // non-trivial generalization. |
| 1965 TestReconfigureElementsKind_GeneralizeField( |
| 1966 {kConst, Representation::HeapObject(), current_type}, |
| 1967 {kMutable, Representation::HeapObject(), new_type}, |
| 1968 {kMutable, Representation::HeapObject(), expected_type}); |
| 1969 |
| 1970 TestReconfigureElementsKind_GeneralizeFieldTrivial( |
| 1971 {kMutable, Representation::HeapObject(), current_type}, |
| 1972 {kConst, Representation::HeapObject(), new_type}, |
| 1973 {kMutable, Representation::HeapObject(), expected_type}); |
| 1974 } |
1800 TestReconfigureElementsKind_GeneralizeFieldTrivial( | 1975 TestReconfigureElementsKind_GeneralizeFieldTrivial( |
1801 {kMutable, Representation::HeapObject(), current_type}, | 1976 {kMutable, Representation::HeapObject(), current_type}, |
1802 {kMutable, Representation::HeapObject(), new_type}, | 1977 {kMutable, Representation::HeapObject(), new_type}, |
1803 {kMutable, Representation::HeapObject(), expected_type}); | 1978 {kMutable, Representation::HeapObject(), expected_type}); |
1804 current_type = expected_type; | 1979 current_type = expected_type; |
1805 | 1980 |
| 1981 // Check generalizations that do not trigger deopts. |
1806 new_type = FieldType::Class(Map::Create(isolate, 0), isolate); | 1982 new_type = FieldType::Class(Map::Create(isolate, 0), isolate); |
1807 | 1983 |
| 1984 if (FLAG_track_constant_fields) { |
| 1985 TestReconfigureElementsKind_GeneralizeFieldTrivial( |
| 1986 {kConst, Representation::HeapObject(), any_type}, |
| 1987 {kConst, Representation::HeapObject(), new_type}, |
| 1988 {kConst, Representation::HeapObject(), any_type}, false); |
| 1989 |
| 1990 // Currently, kConst to kMutable migration causes map change, therefore |
| 1991 // non-trivial generalization. |
| 1992 TestReconfigureElementsKind_GeneralizeField( |
| 1993 {kConst, Representation::HeapObject(), any_type}, |
| 1994 {kMutable, Representation::HeapObject(), new_type}, |
| 1995 {kMutable, Representation::HeapObject(), any_type}); |
| 1996 |
| 1997 TestReconfigureElementsKind_GeneralizeFieldTrivial( |
| 1998 {kMutable, Representation::HeapObject(), any_type}, |
| 1999 {kConst, Representation::HeapObject(), new_type}, |
| 2000 {kMutable, Representation::HeapObject(), any_type}, false); |
| 2001 } |
1808 TestReconfigureElementsKind_GeneralizeFieldTrivial( | 2002 TestReconfigureElementsKind_GeneralizeFieldTrivial( |
1809 {kMutable, Representation::HeapObject(), any_type}, | 2003 {kMutable, Representation::HeapObject(), any_type}, |
1810 {kMutable, Representation::HeapObject(), new_type}, | 2004 {kMutable, Representation::HeapObject(), new_type}, |
1811 {kMutable, Representation::HeapObject(), any_type}, false); | 2005 {kMutable, Representation::HeapObject(), any_type}, false); |
1812 } | 2006 } |
1813 | 2007 |
1814 TEST(ReconfigureElementsKind_GeneralizeHeapObjectFieldToTagged) { | 2008 TEST(ReconfigureElementsKind_GeneralizeHeapObjectFieldToTagged) { |
1815 CcTest::InitializeVM(); | 2009 CcTest::InitializeVM(); |
1816 v8::HandleScope scope(CcTest::isolate()); | 2010 v8::HandleScope scope(CcTest::isolate()); |
1817 Isolate* isolate = CcTest::i_isolate(); | 2011 Isolate* isolate = CcTest::i_isolate(); |
1818 Handle<FieldType> any_type = FieldType::Any(isolate); | 2012 Handle<FieldType> any_type = FieldType::Any(isolate); |
1819 Handle<FieldType> value_type = | 2013 Handle<FieldType> value_type = |
1820 FieldType::Class(Map::Create(isolate, 0), isolate); | 2014 FieldType::Class(Map::Create(isolate, 0), isolate); |
1821 | 2015 |
| 2016 if (FLAG_track_constant_fields) { |
| 2017 TestReconfigureElementsKind_GeneralizeField( |
| 2018 {kConst, Representation::HeapObject(), value_type}, |
| 2019 {kConst, Representation::Smi(), any_type}, |
| 2020 {kConst, Representation::Tagged(), any_type}); |
| 2021 |
| 2022 TestReconfigureElementsKind_GeneralizeField( |
| 2023 {kConst, Representation::HeapObject(), value_type}, |
| 2024 {kMutable, Representation::Smi(), any_type}, |
| 2025 {kMutable, Representation::Tagged(), any_type}); |
| 2026 |
| 2027 TestReconfigureElementsKind_GeneralizeField( |
| 2028 {kMutable, Representation::HeapObject(), value_type}, |
| 2029 {kConst, Representation::Smi(), any_type}, |
| 2030 {kMutable, Representation::Tagged(), any_type}); |
| 2031 } |
1822 TestReconfigureElementsKind_GeneralizeField( | 2032 TestReconfigureElementsKind_GeneralizeField( |
1823 {kMutable, Representation::HeapObject(), value_type}, | 2033 {kMutable, Representation::HeapObject(), value_type}, |
1824 {kMutable, Representation::Smi(), any_type}, | 2034 {kMutable, Representation::Smi(), any_type}, |
1825 {kMutable, Representation::Tagged(), any_type}); | 2035 {kMutable, Representation::Tagged(), any_type}); |
1826 } | 2036 } |
1827 | 2037 |
1828 //////////////////////////////////////////////////////////////////////////////// | 2038 //////////////////////////////////////////////////////////////////////////////// |
1829 // A set of tests checking split map deprecation. | 2039 // A set of tests checking split map deprecation. |
1830 // | 2040 // |
1831 | 2041 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 // transition tree. | 2087 // transition tree. |
1878 CHECK(map->is_deprecated()); | 2088 CHECK(map->is_deprecated()); |
1879 CHECK(!split_map->is_deprecated()); | 2089 CHECK(!split_map->is_deprecated()); |
1880 CHECK(map2->is_stable()); | 2090 CHECK(map2->is_stable()); |
1881 CHECK(!map2->is_deprecated()); | 2091 CHECK(!map2->is_deprecated()); |
1882 | 2092 |
1883 // Fill in transition tree of |map2| so that it can't have more transitions. | 2093 // Fill in transition tree of |map2| so that it can't have more transitions. |
1884 for (int i = 0; i < TransitionArray::kMaxNumberOfTransitions; i++) { | 2094 for (int i = 0; i < TransitionArray::kMaxNumberOfTransitions; i++) { |
1885 CHECK(TransitionArray::CanHaveMoreTransitions(map2)); | 2095 CHECK(TransitionArray::CanHaveMoreTransitions(map2)); |
1886 Handle<String> name = MakeName("foo", i); | 2096 Handle<String> name = MakeName("foo", i); |
1887 Map::CopyWithField(map2, name, any_type, NONE, Representation::Smi(), | 2097 Map::CopyWithField(map2, name, any_type, NONE, kMutable, |
1888 INSERT_TRANSITION) | 2098 Representation::Smi(), INSERT_TRANSITION) |
1889 .ToHandleChecked(); | 2099 .ToHandleChecked(); |
1890 } | 2100 } |
1891 CHECK(!TransitionArray::CanHaveMoreTransitions(map2)); | 2101 CHECK(!TransitionArray::CanHaveMoreTransitions(map2)); |
1892 | 2102 |
1893 // Try to update |map|, since there is no place for propX transition at |map2| | 2103 // Try to update |map|, since there is no place for propX transition at |map2| |
1894 // |map| should become "copy-generalized". | 2104 // |map| should become "copy-generalized". |
1895 Handle<Map> updated_map = Map::Update(map); | 2105 Handle<Map> updated_map = Map::Update(map); |
1896 CHECK(updated_map->GetBackPointer()->IsUndefined(isolate)); | 2106 CHECK(updated_map->GetBackPointer()->IsUndefined(isolate)); |
1897 | 2107 |
1898 for (int i = 0; i < kPropCount; i++) { | 2108 for (int i = 0; i < kPropCount; i++) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2051 FieldType::Class(Map::Create(isolate, 0), isolate); | 2261 FieldType::Class(Map::Create(isolate, 0), isolate); |
2052 | 2262 |
2053 struct TestConfig { | 2263 struct TestConfig { |
2054 Handle<Map> Transition(Handle<Map> map, Expectations& expectations) { | 2264 Handle<Map> Transition(Handle<Map> map, Expectations& expectations) { |
2055 Isolate* isolate = CcTest::i_isolate(); | 2265 Isolate* isolate = CcTest::i_isolate(); |
2056 Handle<FieldType> any_type = FieldType::Any(isolate); | 2266 Handle<FieldType> any_type = FieldType::Any(isolate); |
2057 | 2267 |
2058 // Add one more transition to |map| in order to prevent descriptors | 2268 // Add one more transition to |map| in order to prevent descriptors |
2059 // ownership. | 2269 // ownership. |
2060 CHECK(map->owns_descriptors()); | 2270 CHECK(map->owns_descriptors()); |
2061 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, | 2271 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, kMutable, |
2062 Representation::Smi(), INSERT_TRANSITION) | 2272 Representation::Smi(), INSERT_TRANSITION) |
2063 .ToHandleChecked(); | 2273 .ToHandleChecked(); |
2064 CHECK(!map->owns_descriptors()); | 2274 CHECK(!map->owns_descriptors()); |
2065 | 2275 |
2066 Handle<Symbol> frozen_symbol(map->GetHeap()->frozen_symbol()); | 2276 Handle<Symbol> frozen_symbol(map->GetHeap()->frozen_symbol()); |
2067 expectations.SetElementsKind(DICTIONARY_ELEMENTS); | 2277 expectations.SetElementsKind(DICTIONARY_ELEMENTS); |
2068 return Map::CopyForPreventExtensions(map, NONE, frozen_symbol, | 2278 return Map::CopyForPreventExtensions(map, NONE, frozen_symbol, |
2069 "CopyForPreventExtensions"); | 2279 "CopyForPreventExtensions"); |
2070 } | 2280 } |
2071 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. | 2281 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2133 prototype_ = factory->NewJSObjectFromMap(Map::Create(isolate, 0)); | 2343 prototype_ = factory->NewJSObjectFromMap(Map::Create(isolate, 0)); |
2134 } | 2344 } |
2135 | 2345 |
2136 Handle<Map> Transition(Handle<Map> map, Expectations& expectations) { | 2346 Handle<Map> Transition(Handle<Map> map, Expectations& expectations) { |
2137 Isolate* isolate = CcTest::i_isolate(); | 2347 Isolate* isolate = CcTest::i_isolate(); |
2138 Handle<FieldType> any_type = FieldType::Any(isolate); | 2348 Handle<FieldType> any_type = FieldType::Any(isolate); |
2139 | 2349 |
2140 // Add one more transition to |map| in order to prevent descriptors | 2350 // Add one more transition to |map| in order to prevent descriptors |
2141 // ownership. | 2351 // ownership. |
2142 CHECK(map->owns_descriptors()); | 2352 CHECK(map->owns_descriptors()); |
2143 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, | 2353 Map::CopyWithField(map, MakeString("foo"), any_type, NONE, kMutable, |
2144 Representation::Smi(), INSERT_TRANSITION) | 2354 Representation::Smi(), INSERT_TRANSITION) |
2145 .ToHandleChecked(); | 2355 .ToHandleChecked(); |
2146 CHECK(!map->owns_descriptors()); | 2356 CHECK(!map->owns_descriptors()); |
2147 | 2357 |
2148 return Map::TransitionToPrototype(map, prototype_, REGULAR_PROTOTYPE); | 2358 return Map::TransitionToPrototype(map, prototype_, REGULAR_PROTOTYPE); |
2149 } | 2359 } |
2150 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. | 2360 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. |
2151 bool generalizes_representations() const { | 2361 bool generalizes_representations() const { |
2152 return !IS_PROTO_TRANS_ISSUE_FIXED; | 2362 return !IS_PROTO_TRANS_ISSUE_FIXED; |
2153 } | 2363 } |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2404 CHECK(sloppy_map->is_stable()); | 2614 CHECK(sloppy_map->is_stable()); |
2405 | 2615 |
2406 Handle<JSFunction> js_func1 = | 2616 Handle<JSFunction> js_func1 = |
2407 factory->NewFunction(sloppy_map, info, isolate->native_context()); | 2617 factory->NewFunction(sloppy_map, info, isolate->native_context()); |
2408 TransitionToDataConstantOperator transition_op1(js_func1); | 2618 TransitionToDataConstantOperator transition_op1(js_func1); |
2409 | 2619 |
2410 Handle<JSFunction> js_func2 = | 2620 Handle<JSFunction> js_func2 = |
2411 factory->NewFunction(sloppy_map, info, isolate->native_context()); | 2621 factory->NewFunction(sloppy_map, info, isolate->native_context()); |
2412 TransitionToDataConstantOperator transition_op2(js_func2); | 2622 TransitionToDataConstantOperator transition_op2(js_func2); |
2413 | 2623 |
2414 FieldGeneralizationChecker checker( | 2624 if (FLAG_track_constant_fields) { |
2415 kPropCount - 1, kMutable, Representation::HeapObject(), function_type); | 2625 SameMapChecker checker; |
2416 TestTransitionTo(transition_op1, transition_op2, checker); | 2626 TestTransitionTo(transition_op1, transition_op2, checker); |
| 2627 |
| 2628 } else { |
| 2629 FieldGeneralizationChecker checker( |
| 2630 kPropCount - 1, kMutable, Representation::HeapObject(), function_type); |
| 2631 TestTransitionTo(transition_op1, transition_op2, checker); |
| 2632 } |
2417 } | 2633 } |
2418 | 2634 |
2419 | 2635 |
2420 TEST(TransitionDataConstantToDataField) { | 2636 TEST(TransitionDataConstantToDataField) { |
2421 CcTest::InitializeVM(); | 2637 CcTest::InitializeVM(); |
2422 v8::HandleScope scope(CcTest::isolate()); | 2638 v8::HandleScope scope(CcTest::isolate()); |
2423 Isolate* isolate = CcTest::i_isolate(); | 2639 Isolate* isolate = CcTest::i_isolate(); |
2424 Factory* factory = isolate->factory(); | 2640 Factory* factory = isolate->factory(); |
2425 Handle<FieldType> any_type = FieldType::Any(isolate); | 2641 Handle<FieldType> any_type = FieldType::Any(isolate); |
2426 | 2642 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2482 Handle<Object> obj = | 2698 Handle<Object> obj = |
2483 Object::NewStorageFor(isolate, isolate->factory()->uninitialized_value(), | 2699 Object::NewStorageFor(isolate, isolate->factory()->uninitialized_value(), |
2484 Representation::Double()); | 2700 Representation::Double()); |
2485 CHECK(obj->IsMutableHeapNumber()); | 2701 CHECK(obj->IsMutableHeapNumber()); |
2486 CHECK_EQ(kHoleNanInt64, HeapNumber::cast(*obj)->value_as_bits()); | 2702 CHECK_EQ(kHoleNanInt64, HeapNumber::cast(*obj)->value_as_bits()); |
2487 | 2703 |
2488 obj = Object::NewStorageFor(isolate, mhn, Representation::Double()); | 2704 obj = Object::NewStorageFor(isolate, mhn, Representation::Double()); |
2489 CHECK(obj->IsMutableHeapNumber()); | 2705 CHECK(obj->IsMutableHeapNumber()); |
2490 CHECK_EQ(kHoleNanInt64, HeapNumber::cast(*obj)->value_as_bits()); | 2706 CHECK_EQ(kHoleNanInt64, HeapNumber::cast(*obj)->value_as_bits()); |
2491 } | 2707 } |
OLD | NEW |