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

Side by Side Diff: test/cctest/test-migrations.cc

Issue 980573002: Simplify and compact transitions storage (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix -Werror=pedantic ( rebase Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-transitions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 335
336 Handle<Map> FollowDataTransition(Handle<Map> map, 336 Handle<Map> FollowDataTransition(Handle<Map> map,
337 PropertyAttributes attributes, 337 PropertyAttributes attributes,
338 Representation representation, 338 Representation representation,
339 Handle<HeapType> heap_type) { 339 Handle<HeapType> heap_type) {
340 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); 340 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors());
341 int property_index = number_of_properties_++; 341 int property_index = number_of_properties_++;
342 SetDataField(property_index, attributes, representation, heap_type); 342 SetDataField(property_index, attributes, representation, heap_type);
343 343
344 Handle<String> name = MakeName("prop", property_index); 344 Handle<String> name = MakeName("prop", property_index);
345 int t = map->SearchTransition(kData, *name, attributes); 345 Map* target =
346 CHECK_NE(TransitionArray::kNotFound, t); 346 TransitionArray::SearchTransition(*map, kData, *name, attributes);
347 return handle(map->GetTransition(t)); 347 CHECK(target != NULL);
348 return handle(target);
348 } 349 }
349 350
350 Handle<Map> AddAccessorConstant(Handle<Map> map, 351 Handle<Map> AddAccessorConstant(Handle<Map> map,
351 PropertyAttributes attributes, 352 PropertyAttributes attributes,
352 Handle<AccessorPair> pair) { 353 Handle<AccessorPair> pair) {
353 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors()); 354 CHECK_EQ(number_of_properties_, map->NumberOfOwnDescriptors());
354 int property_index = number_of_properties_++; 355 int property_index = number_of_properties_++;
355 SetAccessorConstant(property_index, attributes, pair); 356 SetAccessorConstant(property_index, attributes, pair);
356 357
357 Handle<String> name = MakeName("prop", property_index); 358 Handle<String> name = MakeName("prop", property_index);
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 const int kSplitProp = kPropCount / 2; 1471 const int kSplitProp = kPropCount / 2;
1471 Handle<Map> split_map; 1472 Handle<Map> split_map;
1472 Handle<Map> map2 = initial_map; 1473 Handle<Map> map2 = initial_map;
1473 { 1474 {
1474 for (int i = 0; i < kSplitProp + 1; i++) { 1475 for (int i = 0; i < kSplitProp + 1; i++) {
1475 if (i == kSplitProp) { 1476 if (i == kSplitProp) {
1476 split_map = map2; 1477 split_map = map2;
1477 } 1478 }
1478 1479
1479 Handle<String> name = MakeName("prop", i); 1480 Handle<String> name = MakeName("prop", i);
1480 int t = map2->SearchTransition(kData, *name, NONE); 1481 Map* target =
1481 CHECK_NE(TransitionArray::kNotFound, t); 1482 TransitionArray::SearchTransition(*map2, kData, *name, NONE);
1482 map2 = handle(map2->GetTransition(t)); 1483 CHECK(target != NULL);
1484 map2 = handle(target);
1483 } 1485 }
1484 1486
1485 map2 = Map::ReconfigureProperty(map2, kSplitProp, kData, NONE, 1487 map2 = Map::ReconfigureProperty(map2, kSplitProp, kData, NONE,
1486 Representation::Double(), any_type, 1488 Representation::Double(), any_type,
1487 FORCE_FIELD); 1489 FORCE_FIELD);
1488 expectations.SetDataField(kSplitProp, Representation::Double(), any_type); 1490 expectations.SetDataField(kSplitProp, Representation::Double(), any_type);
1489 1491
1490 CHECK(expectations.Check(*split_map, kSplitProp)); 1492 CHECK(expectations.Check(*split_map, kSplitProp));
1491 CHECK(expectations.Check(*map2, kSplitProp + 1)); 1493 CHECK(expectations.Check(*map2, kSplitProp + 1));
1492 } 1494 }
1493 1495
1494 // At this point |map| should be deprecated and disconnected from the 1496 // At this point |map| should be deprecated and disconnected from the
1495 // transition tree. 1497 // transition tree.
1496 CHECK(map->is_deprecated()); 1498 CHECK(map->is_deprecated());
1497 CHECK(!split_map->is_deprecated()); 1499 CHECK(!split_map->is_deprecated());
1498 CHECK(!map2->is_deprecated()); 1500 CHECK(!map2->is_deprecated());
1499 1501
1500 // Fill in transition tree of |map2| so that it can't have more transitions. 1502 // Fill in transition tree of |map2| so that it can't have more transitions.
1501 for (int i = 0; i < TransitionArray::kMaxNumberOfTransitions; i++) { 1503 for (int i = 0; i < TransitionArray::kMaxNumberOfTransitions; i++) {
1502 CHECK(map2->CanHaveMoreTransitions()); 1504 CHECK(TransitionArray::CanHaveMoreTransitions(map2));
1503 Handle<String> name = MakeName("foo", i); 1505 Handle<String> name = MakeName("foo", i);
1504 Map::CopyWithField(map2, name, any_type, NONE, Representation::Smi(), 1506 Map::CopyWithField(map2, name, any_type, NONE, Representation::Smi(),
1505 INSERT_TRANSITION).ToHandleChecked(); 1507 INSERT_TRANSITION).ToHandleChecked();
1506 } 1508 }
1507 CHECK(!map2->CanHaveMoreTransitions()); 1509 CHECK(!TransitionArray::CanHaveMoreTransitions(map2));
1508 1510
1509 // Try to update |map|, since there is no place for propX transition at |map2| 1511 // Try to update |map|, since there is no place for propX transition at |map2|
1510 // |map| should become "copy-generalized". 1512 // |map| should become "copy-generalized".
1511 Handle<Map> updated_map = Map::Update(map); 1513 Handle<Map> updated_map = Map::Update(map);
1512 CHECK(updated_map->GetBackPointer()->IsUndefined()); 1514 CHECK(updated_map->GetBackPointer()->IsUndefined());
1513 1515
1514 for (int i = 0; i < kPropCount; i++) { 1516 for (int i = 0; i < kPropCount; i++) {
1515 expectations.SetDataField(i, Representation::Tagged(), any_type); 1517 expectations.SetDataField(i, Representation::Tagged(), any_type);
1516 } 1518 }
1517 CHECK(expectations.Check(*updated_map)); 1519 CHECK(expectations.Check(*updated_map));
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 Handle<AccessorPair> pair = CreateAccessorPair(true, true); 2079 Handle<AccessorPair> pair = CreateAccessorPair(true, true);
2078 TransitionToAccessorConstantOperator transition_op(pair); 2080 TransitionToAccessorConstantOperator transition_op(pair);
2079 2081
2080 SameMapChecker checker; 2082 SameMapChecker checker;
2081 TestTransitionTo(transition_op, transition_op, checker); 2083 TestTransitionTo(transition_op, transition_op, checker);
2082 } 2084 }
2083 2085
2084 2086
2085 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. 2087 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported.
2086 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) 2088 // TEST(TransitionAccessorConstantToAnotherAccessorConstant)
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-transitions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698