Commit 1228306d authored by ishell's avatar ishell Committed by Commit bot

Rename GeneralizeRepresentation term to GeneralizeField in tests.

BUG=

Review-Url: https://codereview.chromium.org/2644843002
Cr-Commit-Position: refs/heads/master@{#42498}
parent 1dcd8b23
...@@ -24,7 +24,7 @@ using namespace v8::internal; ...@@ -24,7 +24,7 @@ using namespace v8::internal;
// TODO(ishell): fix this once TransitionToPrototype stops generalizing // TODO(ishell): fix this once TransitionToPrototype stops generalizing
// all field representations (similar to crbug/448711 where elements kind // all field representations (similar to crbug/448711 where elements kind
// and observed transitions caused generalization of all field representations). // and observed transitions caused generalization of all fields).
const bool IS_PROTO_TRANS_ISSUE_FIXED = false; const bool IS_PROTO_TRANS_ISSUE_FIXED = false;
...@@ -221,7 +221,7 @@ class Expectations { ...@@ -221,7 +221,7 @@ class Expectations {
SetAccessorConstant(index, getter, setter); SetAccessorConstant(index, getter, setter);
} }
void GeneralizeRepresentation(int index) { void GeneralizeField(int index) {
CHECK(index < number_of_properties_); CHECK(index < number_of_properties_);
representations_[index] = Representation::Tagged(); representations_[index] = Representation::Tagged();
if (locations_[index] == kField) { if (locations_[index] == kField) {
...@@ -548,7 +548,7 @@ TEST(ReconfigureAccessorToNonExistingDataFieldHeavy) { ...@@ -548,7 +548,7 @@ TEST(ReconfigureAccessorToNonExistingDataFieldHeavy) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// A set of tests for representation generalization case. // A set of tests for field generalization case.
// //
// <Constness, Representation, FieldType> data. // <Constness, Representation, FieldType> data.
...@@ -558,9 +558,9 @@ struct CRFTData { ...@@ -558,9 +558,9 @@ struct CRFTData {
Handle<FieldType> type; Handle<FieldType> type;
}; };
// This test ensures that representation/field type generalization at // This test ensures that field generalization at |property_index| is done
// |property_index| is done correctly independently of the fact that the |map| // correctly independently of the fact that the |map| is detached from
// is detached from transition tree or not. // transition tree or not.
// //
// {} - p0 - p1 - p2: |detach_point_map| // {} - p0 - p1 - p2: |detach_point_map|
// | // |
...@@ -570,10 +570,11 @@ struct CRFTData { ...@@ -570,10 +570,11 @@ struct CRFTData {
// //
// Detaching does not happen if |detach_property_at_index| is -1. // Detaching does not happen if |detach_property_at_index| is -1.
// //
static void TestGeneralizeRepresentation( static void TestGeneralizeField(int detach_property_at_index,
int detach_property_at_index, int property_index, const CRFTData& from, int property_index, const CRFTData& from,
const CRFTData& to, const CRFTData& expected, bool expected_deprecation, const CRFTData& to, const CRFTData& expected,
bool expected_field_type_dependency) { bool expected_deprecation,
bool expected_field_type_dependency) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Handle<FieldType> any_type = FieldType::Any(isolate); Handle<FieldType> any_type = FieldType::Any(isolate);
...@@ -675,19 +676,17 @@ static void TestGeneralizeRepresentation( ...@@ -675,19 +676,17 @@ static void TestGeneralizeRepresentation(
CHECK_EQ(*new_map, *updated_map); CHECK_EQ(*new_map, *updated_map);
} }
static void TestGeneralizeRepresentation(const CRFTData& from, static void TestGeneralizeField(const CRFTData& from, const CRFTData& to,
const CRFTData& to, const CRFTData& expected,
const CRFTData& expected, bool expected_deprecation,
bool expected_deprecation, bool expected_field_type_dependency) {
bool expected_field_type_dependency) {
// Check the cases when the map being reconfigured is a part of the // Check the cases when the map being reconfigured is a part of the
// transition tree. // transition tree.
STATIC_ASSERT(kPropCount > 4); STATIC_ASSERT(kPropCount > 4);
int indices[] = {0, 2, kPropCount - 1}; int indices[] = {0, 2, kPropCount - 1};
for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) {
TestGeneralizeRepresentation(-1, indices[i], from, to, expected, TestGeneralizeField(-1, indices[i], from, to, expected,
expected_deprecation, expected_deprecation, expected_field_type_dependency);
expected_field_type_dependency);
} }
if (!from.representation.IsNone()) { if (!from.representation.IsNone()) {
...@@ -696,50 +695,46 @@ static void TestGeneralizeRepresentation(const CRFTData& from, ...@@ -696,50 +695,46 @@ static void TestGeneralizeRepresentation(const CRFTData& from,
// only for "attached" maps. // only for "attached" maps.
int indices[] = {0, kPropCount - 1}; int indices[] = {0, kPropCount - 1};
for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) {
TestGeneralizeRepresentation(indices[i], 2, from, to, expected, TestGeneralizeField(indices[i], 2, from, to, expected,
expected_deprecation, expected_deprecation, expected_field_type_dependency);
expected_field_type_dependency);
} }
// Check that reconfiguration to the very same field works correctly. // Check that reconfiguration to the very same field works correctly.
CRFTData data = from; CRFTData data = from;
TestGeneralizeRepresentation(-1, 2, data, data, data, false, false); TestGeneralizeField(-1, 2, data, data, data, false, false);
} }
} }
static void TestGeneralizeRepresentation(const CRFTData& from, static void TestGeneralizeField(const CRFTData& from, const CRFTData& to,
const CRFTData& to, const CRFTData& expected) {
const CRFTData& expected) {
const bool expected_deprecation = true; const bool expected_deprecation = true;
const bool expected_field_type_dependency = false; const bool expected_field_type_dependency = false;
TestGeneralizeRepresentation(from, to, expected, expected_deprecation, TestGeneralizeField(from, to, expected, expected_deprecation,
expected_field_type_dependency); expected_field_type_dependency);
} }
static void TestGeneralizeRepresentationTrivial( static void TestGeneralizeFieldTrivial(
const CRFTData& from, const CRFTData& to, const CRFTData& expected, const CRFTData& from, const CRFTData& to, const CRFTData& expected,
bool expected_field_type_dependency = true) { bool expected_field_type_dependency = true) {
const bool expected_deprecation = false; const bool expected_deprecation = false;
TestGeneralizeRepresentation(from, to, expected, expected_deprecation, TestGeneralizeField(from, to, expected, expected_deprecation,
expected_field_type_dependency); expected_field_type_dependency);
} }
TEST(GeneralizeSmiFieldToDouble) {
TEST(GeneralizeRepresentationSmiToDouble) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Handle<FieldType> any_type = FieldType::Any(isolate); Handle<FieldType> any_type = FieldType::Any(isolate);
TestGeneralizeRepresentation({kMutable, Representation::Smi(), any_type}, TestGeneralizeField({kMutable, Representation::Smi(), any_type},
{kMutable, Representation::Double(), any_type}, {kMutable, Representation::Double(), any_type},
{kMutable, Representation::Double(), any_type}); {kMutable, Representation::Double(), any_type});
} }
TEST(GeneralizeSmiFieldToTagged) {
TEST(GeneralizeRepresentationSmiToTagged) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -747,14 +742,12 @@ TEST(GeneralizeRepresentationSmiToTagged) { ...@@ -747,14 +742,12 @@ TEST(GeneralizeRepresentationSmiToTagged) {
Handle<FieldType> value_type = Handle<FieldType> value_type =
FieldType::Class(Map::Create(isolate, 0), isolate); FieldType::Class(Map::Create(isolate, 0), isolate);
TestGeneralizeRepresentation( TestGeneralizeField({kMutable, Representation::Smi(), any_type},
{kMutable, Representation::Smi(), any_type}, {kMutable, Representation::HeapObject(), value_type},
{kMutable, Representation::HeapObject(), value_type}, {kMutable, Representation::Tagged(), any_type});
{kMutable, Representation::Tagged(), any_type});
} }
TEST(GeneralizeDoubleFieldToTagged) {
TEST(GeneralizeRepresentationDoubleToTagged) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -762,14 +755,12 @@ TEST(GeneralizeRepresentationDoubleToTagged) { ...@@ -762,14 +755,12 @@ TEST(GeneralizeRepresentationDoubleToTagged) {
Handle<FieldType> value_type = Handle<FieldType> value_type =
FieldType::Class(Map::Create(isolate, 0), isolate); FieldType::Class(Map::Create(isolate, 0), isolate);
TestGeneralizeRepresentation( TestGeneralizeField({kMutable, Representation::Double(), any_type},
{kMutable, Representation::Double(), any_type}, {kMutable, Representation::HeapObject(), value_type},
{kMutable, Representation::HeapObject(), value_type}, {kMutable, Representation::Tagged(), any_type});
{kMutable, Representation::Tagged(), any_type});
} }
TEST(GeneralizeHeapObjectFieldToTagged) {
TEST(GeneralizeRepresentationHeapObjectToTagged) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -777,14 +768,12 @@ TEST(GeneralizeRepresentationHeapObjectToTagged) { ...@@ -777,14 +768,12 @@ TEST(GeneralizeRepresentationHeapObjectToTagged) {
Handle<FieldType> value_type = Handle<FieldType> value_type =
FieldType::Class(Map::Create(isolate, 0), isolate); FieldType::Class(Map::Create(isolate, 0), isolate);
TestGeneralizeRepresentation( TestGeneralizeField({kMutable, Representation::HeapObject(), value_type},
{kMutable, Representation::HeapObject(), value_type}, {kMutable, Representation::Smi(), any_type},
{kMutable, Representation::Smi(), any_type}, {kMutable, Representation::Tagged(), any_type});
{kMutable, Representation::Tagged(), any_type});
} }
TEST(GeneralizeHeapObjectFieldToHeapObject) {
TEST(GeneralizeRepresentationHeapObjectToHeapObject) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -798,7 +787,7 @@ TEST(GeneralizeRepresentationHeapObjectToHeapObject) { ...@@ -798,7 +787,7 @@ TEST(GeneralizeRepresentationHeapObjectToHeapObject) {
Handle<FieldType> expected_type = any_type; Handle<FieldType> expected_type = any_type;
TestGeneralizeRepresentationTrivial( TestGeneralizeFieldTrivial(
{kMutable, Representation::HeapObject(), current_type}, {kMutable, Representation::HeapObject(), current_type},
{kMutable, Representation::HeapObject(), new_type}, {kMutable, Representation::HeapObject(), new_type},
{kMutable, Representation::HeapObject(), expected_type}); {kMutable, Representation::HeapObject(), expected_type});
...@@ -806,14 +795,13 @@ TEST(GeneralizeRepresentationHeapObjectToHeapObject) { ...@@ -806,14 +795,13 @@ TEST(GeneralizeRepresentationHeapObjectToHeapObject) {
new_type = FieldType::Class(Map::Create(isolate, 0), isolate); new_type = FieldType::Class(Map::Create(isolate, 0), isolate);
TestGeneralizeRepresentationTrivial( TestGeneralizeFieldTrivial({kMutable, Representation::HeapObject(), any_type},
{kMutable, Representation::HeapObject(), any_type}, {kMutable, Representation::HeapObject(), new_type},
{kMutable, Representation::HeapObject(), new_type}, {kMutable, Representation::HeapObject(), any_type},
{kMutable, Representation::HeapObject(), any_type}, false); false);
} }
TEST(GeneralizeNoneFieldToSmi) {
TEST(GeneralizeRepresentationNoneToSmi) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -821,14 +809,12 @@ TEST(GeneralizeRepresentationNoneToSmi) { ...@@ -821,14 +809,12 @@ TEST(GeneralizeRepresentationNoneToSmi) {
Handle<FieldType> any_type = FieldType::Any(isolate); Handle<FieldType> any_type = FieldType::Any(isolate);
// None -> Smi representation change is trivial. // None -> Smi representation change is trivial.
TestGeneralizeRepresentationTrivial( TestGeneralizeFieldTrivial({kMutable, Representation::None(), none_type},
{kMutable, Representation::None(), none_type}, {kMutable, Representation::Smi(), any_type},
{kMutable, Representation::Smi(), any_type}, {kMutable, Representation::Smi(), any_type});
{kMutable, Representation::Smi(), any_type});
} }
TEST(GeneralizeNoneFieldToDouble) {
TEST(GeneralizeRepresentationNoneToDouble) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -836,13 +822,12 @@ TEST(GeneralizeRepresentationNoneToDouble) { ...@@ -836,13 +822,12 @@ TEST(GeneralizeRepresentationNoneToDouble) {
Handle<FieldType> any_type = FieldType::Any(isolate); Handle<FieldType> any_type = FieldType::Any(isolate);
// None -> Double representation change is NOT trivial. // None -> Double representation change is NOT trivial.
TestGeneralizeRepresentation({kMutable, Representation::None(), none_type}, TestGeneralizeField({kMutable, Representation::None(), none_type},
{kMutable, Representation::Double(), any_type}, {kMutable, Representation::Double(), any_type},
{kMutable, Representation::Double(), any_type}); {kMutable, Representation::Double(), any_type});
} }
TEST(GeneralizeNoneFieldToHeapObject) {
TEST(GeneralizeRepresentationNoneToHeapObject) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -851,14 +836,13 @@ TEST(GeneralizeRepresentationNoneToHeapObject) { ...@@ -851,14 +836,13 @@ TEST(GeneralizeRepresentationNoneToHeapObject) {
FieldType::Class(Map::Create(isolate, 0), isolate); FieldType::Class(Map::Create(isolate, 0), isolate);
// None -> HeapObject representation change is trivial. // None -> HeapObject representation change is trivial.
TestGeneralizeRepresentationTrivial( TestGeneralizeFieldTrivial(
{kMutable, Representation::None(), none_type}, {kMutable, Representation::None(), none_type},
{kMutable, Representation::HeapObject(), value_type}, {kMutable, Representation::HeapObject(), value_type},
{kMutable, Representation::HeapObject(), value_type}); {kMutable, Representation::HeapObject(), value_type});
} }
TEST(GeneralizeNoneFieldToTagged) {
TEST(GeneralizeRepresentationNoneToTagged) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -866,19 +850,17 @@ TEST(GeneralizeRepresentationNoneToTagged) { ...@@ -866,19 +850,17 @@ TEST(GeneralizeRepresentationNoneToTagged) {
Handle<FieldType> any_type = FieldType::Any(isolate); Handle<FieldType> any_type = FieldType::Any(isolate);
// None -> HeapObject representation change is trivial. // None -> HeapObject representation change is trivial.
TestGeneralizeRepresentationTrivial( TestGeneralizeFieldTrivial({kMutable, Representation::None(), none_type},
{kMutable, Representation::None(), none_type}, {kMutable, Representation::Tagged(), any_type},
{kMutable, Representation::Tagged(), any_type}, {kMutable, Representation::Tagged(), any_type});
{kMutable, Representation::Tagged(), any_type});
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// A set of tests for representation generalization case with kAccessor // A set of tests for field generalization case with kAccessor properties.
// properties.
// //
TEST(GeneralizeRepresentationWithAccessorProperties) { TEST(GeneralizeFieldWithAccessorProperties) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -943,8 +925,8 @@ TEST(GeneralizeRepresentationWithAccessorProperties) { ...@@ -943,8 +925,8 @@ TEST(GeneralizeRepresentationWithAccessorProperties) {
// A set of tests for attribute reconfiguration case. // A set of tests for attribute reconfiguration case.
// //
// This test ensures that representation/field type generalization is correctly // This test ensures that field generalization is correctly propagated from one
// propagated from one branch of transition tree (|map2|) to another (|map|). // branch of transition tree (|map2|) to another (|map|).
// //
// + - p2B - p3 - p4: |map2| // + - p2B - p3 - p4: |map2|
// | // |
...@@ -952,7 +934,7 @@ TEST(GeneralizeRepresentationWithAccessorProperties) { ...@@ -952,7 +934,7 @@ TEST(GeneralizeRepresentationWithAccessorProperties) {
// //
// where "p2A" and "p2B" differ only in the attributes. // where "p2A" and "p2B" differ only in the attributes.
// //
static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation( static void TestReconfigureDataFieldAttribute_GeneralizeField(
const CRFTData& from, const CRFTData& to, const CRFTData& expected) { const CRFTData& from, const CRFTData& to, const CRFTData& expected) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -1026,10 +1008,9 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation( ...@@ -1026,10 +1008,9 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation(
CHECK_EQ(*new_map, *updated_map); CHECK_EQ(*new_map, *updated_map);
} }
// This test ensures that trivial field generalization (from HeapObject to
// This test ensures that trivial representation/field type generalization // HeapObject) is correctly propagated from one branch of transition tree
// (from HeapObject to HeapObject) is correctly propagated from one branch of // (|map2|) to another (|map|).
// transition tree (|map2|) to another (|map|).
// //
// + - p2B - p3 - p4: |map2| // + - p2B - p3 - p4: |map2|
// | // |
...@@ -1037,7 +1018,7 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation( ...@@ -1037,7 +1018,7 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation(
// //
// where "p2A" and "p2B" differ only in the attributes. // where "p2A" and "p2B" differ only in the attributes.
// //
static void TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( static void TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial(
const CRFTData& from, const CRFTData& to, const CRFTData& expected, const CRFTData& from, const CRFTData& to, const CRFTData& expected,
bool expected_field_type_dependency = true) { bool expected_field_type_dependency = true) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -1114,21 +1095,19 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( ...@@ -1114,21 +1095,19 @@ static void TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial(
CHECK_EQ(*new_map, *updated_map); CHECK_EQ(*new_map, *updated_map);
} }
TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToDouble) {
TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToDouble) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Handle<FieldType> any_type = FieldType::Any(isolate); Handle<FieldType> any_type = FieldType::Any(isolate);
TestReconfigureDataFieldAttribute_GeneralizeRepresentation( TestReconfigureDataFieldAttribute_GeneralizeField(
{kMutable, Representation::Smi(), any_type}, {kMutable, Representation::Smi(), any_type},
{kMutable, Representation::Double(), any_type}, {kMutable, Representation::Double(), any_type},
{kMutable, Representation::Double(), any_type}); {kMutable, Representation::Double(), any_type});
} }
TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToTagged) {
TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToTagged) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -1136,14 +1115,13 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToTagged) { ...@@ -1136,14 +1115,13 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToTagged) {
Handle<FieldType> value_type = Handle<FieldType> value_type =
FieldType::Class(Map::Create(isolate, 0), isolate); FieldType::Class(Map::Create(isolate, 0), isolate);
TestReconfigureDataFieldAttribute_GeneralizeRepresentation( TestReconfigureDataFieldAttribute_GeneralizeField(
{kMutable, Representation::Smi(), any_type}, {kMutable, Representation::Smi(), any_type},
{kMutable, Representation::HeapObject(), value_type}, {kMutable, Representation::HeapObject(), value_type},
{kMutable, Representation::Tagged(), any_type}); {kMutable, Representation::Tagged(), any_type});
} }
TEST(ReconfigureDataFieldAttribute_GeneralizeDoubleFieldToTagged) {
TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationDoubleToTagged) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -1151,14 +1129,13 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationDoubleToTagged) { ...@@ -1151,14 +1129,13 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationDoubleToTagged) {
Handle<FieldType> value_type = Handle<FieldType> value_type =
FieldType::Class(Map::Create(isolate, 0), isolate); FieldType::Class(Map::Create(isolate, 0), isolate);
TestReconfigureDataFieldAttribute_GeneralizeRepresentation( TestReconfigureDataFieldAttribute_GeneralizeField(
{kMutable, Representation::Double(), any_type}, {kMutable, Representation::Double(), any_type},
{kMutable, Representation::HeapObject(), value_type}, {kMutable, Representation::HeapObject(), value_type},
{kMutable, Representation::Tagged(), any_type}); {kMutable, Representation::Tagged(), any_type});
} }
TEST(ReconfigureDataFieldAttribute_GeneralizeHeapObjFieldToHeapObj) {
TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjToHeapObj) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -1172,7 +1149,7 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjToHeapObj) { ...@@ -1172,7 +1149,7 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjToHeapObj) {
Handle<FieldType> expected_type = any_type; Handle<FieldType> expected_type = any_type;
TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial(
{kMutable, Representation::HeapObject(), current_type}, {kMutable, Representation::HeapObject(), current_type},
{kMutable, Representation::HeapObject(), new_type}, {kMutable, Representation::HeapObject(), new_type},
{kMutable, Representation::HeapObject(), expected_type}); {kMutable, Representation::HeapObject(), expected_type});
...@@ -1180,14 +1157,13 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjToHeapObj) { ...@@ -1180,14 +1157,13 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjToHeapObj) {
new_type = FieldType::Class(Map::Create(isolate, 0), isolate); new_type = FieldType::Class(Map::Create(isolate, 0), isolate);
TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial(
{kMutable, Representation::HeapObject(), any_type}, {kMutable, Representation::HeapObject(), any_type},
{kMutable, Representation::HeapObject(), new_type}, {kMutable, Representation::HeapObject(), new_type},
{kMutable, Representation::HeapObject(), any_type}, false); {kMutable, Representation::HeapObject(), any_type}, false);
} }
TEST(ReconfigureDataFieldAttribute_GeneralizeHeapObjectFieldToTagged) {
TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjectToTagged) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -1195,7 +1171,7 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjectToTagged) { ...@@ -1195,7 +1171,7 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjectToTagged) {
Handle<FieldType> value_type = Handle<FieldType> value_type =
FieldType::Class(Map::Create(isolate, 0), isolate); FieldType::Class(Map::Create(isolate, 0), isolate);
TestReconfigureDataFieldAttribute_GeneralizeRepresentation( TestReconfigureDataFieldAttribute_GeneralizeField(
{kMutable, Representation::HeapObject(), value_type}, {kMutable, Representation::HeapObject(), value_type},
{kMutable, Representation::Smi(), any_type}, {kMutable, Representation::Smi(), any_type},
{kMutable, Representation::Tagged(), any_type}); {kMutable, Representation::Tagged(), any_type});
...@@ -1264,7 +1240,7 @@ struct CheckCopyGeneralizeAllFields { ...@@ -1264,7 +1240,7 @@ struct CheckCopyGeneralizeAllFields {
CHECK(new_map->GetBackPointer()->IsUndefined(map->GetIsolate())); CHECK(new_map->GetBackPointer()->IsUndefined(map->GetIsolate()));
for (int i = 0; i < kPropCount; i++) { for (int i = 0; i < kPropCount; i++) {
expectations.GeneralizeRepresentation(i); expectations.GeneralizeField(i);
} }
CHECK(!new_map->is_deprecated()); CHECK(!new_map->is_deprecated());
...@@ -1272,9 +1248,8 @@ struct CheckCopyGeneralizeAllFields { ...@@ -1272,9 +1248,8 @@ struct CheckCopyGeneralizeAllFields {
} }
}; };
// This test ensures that field generalization is correctly propagated from one
// This test ensures that representation/field type generalization is correctly // branch of transition tree (|map2|) to another (|map1|).
// propagated from one branch of transition tree (|map2|) to another (|map1|).
// //
// + - p2B - p3 - p4: |map2| // + - p2B - p3 - p4: |map2|
// | // |
...@@ -1581,8 +1556,8 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) { ...@@ -1581,8 +1556,8 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) {
// A set of tests for elements kind reconfiguration case. // A set of tests for elements kind reconfiguration case.
// //
// This test ensures that representation/field type generalization is correctly // This test ensures that field generalization is correctly propagated from one
// propagated from one branch of transition tree (|map2) to another (|map|). // branch of transition tree (|map2) to another (|map|).
// //
// + - p0 - p1 - p2A - p3 - p4: |map| // + - p0 - p1 - p2A - p3 - p4: |map|
// | // |
...@@ -1592,7 +1567,7 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) { ...@@ -1592,7 +1567,7 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) {
// //
// where "p2A" and "p2B" differ only in the representation/field type. // where "p2A" and "p2B" differ only in the representation/field type.
// //
static void TestReconfigureElementsKind_GeneralizeRepresentation( static void TestReconfigureElementsKind_GeneralizeField(
const CRFTData& from, const CRFTData& to, const CRFTData& expected) { const CRFTData& from, const CRFTData& to, const CRFTData& expected) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -1673,9 +1648,9 @@ static void TestReconfigureElementsKind_GeneralizeRepresentation( ...@@ -1673,9 +1648,9 @@ static void TestReconfigureElementsKind_GeneralizeRepresentation(
} }
} }
// This test ensures that trivial representation/field type generalization // This test ensures that trivial field generalization (from HeapObject to
// (from HeapObject to HeapObject) is correctly propagated from one branch of // HeapObject) is correctly propagated from one branch of transition tree
// transition tree (|map2|) to another (|map|). // (|map2|) to another (|map|).
// //
// + - p0 - p1 - p2A - p3 - p4: |map| // + - p0 - p1 - p2A - p3 - p4: |map|
// | // |
...@@ -1685,7 +1660,7 @@ static void TestReconfigureElementsKind_GeneralizeRepresentation( ...@@ -1685,7 +1660,7 @@ static void TestReconfigureElementsKind_GeneralizeRepresentation(
// //
// where "p2A" and "p2B" differ only in the representation/field type. // where "p2A" and "p2B" differ only in the representation/field type.
// //
static void TestReconfigureElementsKind_GeneralizeRepresentationTrivial( static void TestReconfigureElementsKind_GeneralizeFieldTrivial(
const CRFTData& from, const CRFTData& to, const CRFTData& expected, const CRFTData& from, const CRFTData& to, const CRFTData& expected,
bool expected_field_type_dependency = true) { bool expected_field_type_dependency = true) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -1768,19 +1743,19 @@ static void TestReconfigureElementsKind_GeneralizeRepresentationTrivial( ...@@ -1768,19 +1743,19 @@ static void TestReconfigureElementsKind_GeneralizeRepresentationTrivial(
} }
} }
TEST(ReconfigureElementsKind_GeneralizeRepresentationSmiToDouble) { TEST(ReconfigureElementsKind_GeneralizeSmiFieldToDouble) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Handle<FieldType> any_type = FieldType::Any(isolate); Handle<FieldType> any_type = FieldType::Any(isolate);
TestReconfigureElementsKind_GeneralizeRepresentation( TestReconfigureElementsKind_GeneralizeField(
{kMutable, Representation::Smi(), any_type}, {kMutable, Representation::Smi(), any_type},
{kMutable, Representation::Double(), any_type}, {kMutable, Representation::Double(), any_type},
{kMutable, Representation::Double(), any_type}); {kMutable, Representation::Double(), any_type});
} }
TEST(ReconfigureElementsKind_GeneralizeRepresentationSmiToTagged) { TEST(ReconfigureElementsKind_GeneralizeSmiFieldToTagged) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -1788,13 +1763,13 @@ TEST(ReconfigureElementsKind_GeneralizeRepresentationSmiToTagged) { ...@@ -1788,13 +1763,13 @@ TEST(ReconfigureElementsKind_GeneralizeRepresentationSmiToTagged) {
Handle<FieldType> value_type = Handle<FieldType> value_type =
FieldType::Class(Map::Create(isolate, 0), isolate); FieldType::Class(Map::Create(isolate, 0), isolate);
TestReconfigureElementsKind_GeneralizeRepresentation( TestReconfigureElementsKind_GeneralizeField(
{kMutable, Representation::Smi(), any_type}, {kMutable, Representation::Smi(), any_type},
{kMutable, Representation::HeapObject(), value_type}, {kMutable, Representation::HeapObject(), value_type},
{kMutable, Representation::Tagged(), any_type}); {kMutable, Representation::Tagged(), any_type});
} }
TEST(ReconfigureElementsKind_GeneralizeRepresentationDoubleToTagged) { TEST(ReconfigureElementsKind_GeneralizeDoubleFieldToTagged) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -1802,13 +1777,13 @@ TEST(ReconfigureElementsKind_GeneralizeRepresentationDoubleToTagged) { ...@@ -1802,13 +1777,13 @@ TEST(ReconfigureElementsKind_GeneralizeRepresentationDoubleToTagged) {
Handle<FieldType> value_type = Handle<FieldType> value_type =
FieldType::Class(Map::Create(isolate, 0), isolate); FieldType::Class(Map::Create(isolate, 0), isolate);
TestReconfigureElementsKind_GeneralizeRepresentation( TestReconfigureElementsKind_GeneralizeField(
{kMutable, Representation::Double(), any_type}, {kMutable, Representation::Double(), any_type},
{kMutable, Representation::HeapObject(), value_type}, {kMutable, Representation::HeapObject(), value_type},
{kMutable, Representation::Tagged(), any_type}); {kMutable, Representation::Tagged(), any_type});
} }
TEST(ReconfigureElementsKind_GeneralizeRepresentationHeapObjToHeapObj) { TEST(ReconfigureElementsKind_GeneralizeHeapObjFieldToHeapObj) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -1822,7 +1797,7 @@ TEST(ReconfigureElementsKind_GeneralizeRepresentationHeapObjToHeapObj) { ...@@ -1822,7 +1797,7 @@ TEST(ReconfigureElementsKind_GeneralizeRepresentationHeapObjToHeapObj) {
Handle<FieldType> expected_type = any_type; Handle<FieldType> expected_type = any_type;
TestReconfigureElementsKind_GeneralizeRepresentationTrivial( TestReconfigureElementsKind_GeneralizeFieldTrivial(
{kMutable, Representation::HeapObject(), current_type}, {kMutable, Representation::HeapObject(), current_type},
{kMutable, Representation::HeapObject(), new_type}, {kMutable, Representation::HeapObject(), new_type},
{kMutable, Representation::HeapObject(), expected_type}); {kMutable, Representation::HeapObject(), expected_type});
...@@ -1830,13 +1805,13 @@ TEST(ReconfigureElementsKind_GeneralizeRepresentationHeapObjToHeapObj) { ...@@ -1830,13 +1805,13 @@ TEST(ReconfigureElementsKind_GeneralizeRepresentationHeapObjToHeapObj) {
new_type = FieldType::Class(Map::Create(isolate, 0), isolate); new_type = FieldType::Class(Map::Create(isolate, 0), isolate);
TestReconfigureElementsKind_GeneralizeRepresentationTrivial( TestReconfigureElementsKind_GeneralizeFieldTrivial(
{kMutable, Representation::HeapObject(), any_type}, {kMutable, Representation::HeapObject(), any_type},
{kMutable, Representation::HeapObject(), new_type}, {kMutable, Representation::HeapObject(), new_type},
{kMutable, Representation::HeapObject(), any_type}, false); {kMutable, Representation::HeapObject(), any_type}, false);
} }
TEST(ReconfigureElementsKind_GeneralizeRepresentationHeapObjectToTagged) { TEST(ReconfigureElementsKind_GeneralizeHeapObjectFieldToTagged) {
CcTest::InitializeVM(); CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -1844,7 +1819,7 @@ TEST(ReconfigureElementsKind_GeneralizeRepresentationHeapObjectToTagged) { ...@@ -1844,7 +1819,7 @@ TEST(ReconfigureElementsKind_GeneralizeRepresentationHeapObjectToTagged) {
Handle<FieldType> value_type = Handle<FieldType> value_type =
FieldType::Class(Map::Create(isolate, 0), isolate); FieldType::Class(Map::Create(isolate, 0), isolate);
TestReconfigureElementsKind_GeneralizeRepresentation( TestReconfigureElementsKind_GeneralizeField(
{kMutable, Representation::HeapObject(), value_type}, {kMutable, Representation::HeapObject(), value_type},
{kMutable, Representation::Smi(), any_type}, {kMutable, Representation::Smi(), any_type},
{kMutable, Representation::Tagged(), any_type}); {kMutable, Representation::Tagged(), any_type});
...@@ -1932,8 +1907,8 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) { ...@@ -1932,8 +1907,8 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) {
// transition, observed transition or prototype transition). // transition, observed transition or prototype transition).
// //
// This test ensures that representation/field type generalization is correctly // This test ensures that field generalization is correctly propagated from one
// propagated from one branch of transition tree (|map2|) to another (|map|). // branch of transition tree (|map2|) to another (|map|).
// //
// p4B: |map2| // p4B: |map2|
// | // |
...@@ -1944,13 +1919,14 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) { ...@@ -1944,13 +1919,14 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) {
// where "p4A" and "p4B" are exactly the same properties. // where "p4A" and "p4B" are exactly the same properties.
// //
// TODO(ishell): unify this test template with // TODO(ishell): unify this test template with
// TestReconfigureDataFieldAttribute_GeneralizeRepresentation once // TestReconfigureDataFieldAttribute_GeneralizeField once
// IS_PROTO_TRANS_ISSUE_FIXED and IS_NON_EQUIVALENT_TRANSITION_SUPPORTED are // IS_PROTO_TRANS_ISSUE_FIXED and IS_NON_EQUIVALENT_TRANSITION_SUPPORTED are
// fixed. // fixed.
template <typename TestConfig> template <typename TestConfig>
static void TestGeneralizeRepresentationWithSpecialTransition( static void TestGeneralizeFieldWithSpecialTransition(TestConfig& config,
TestConfig& config, const CRFTData& from, const CRFTData& to, const CRFTData& from,
const CRFTData& expected) { const CRFTData& to,
const CRFTData& expected) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Expectations expectations(isolate); Expectations expectations(isolate);
...@@ -1978,7 +1954,7 @@ static void TestGeneralizeRepresentationWithSpecialTransition( ...@@ -1978,7 +1954,7 @@ static void TestGeneralizeRepresentationWithSpecialTransition(
if (config.generalizes_representations()) { if (config.generalizes_representations()) {
for (int i = 0; i < kPropCount; i++) { for (int i = 0; i < kPropCount; i++) {
expectations2.GeneralizeRepresentation(i); expectations2.GeneralizeField(i);
} }
} }
...@@ -2016,7 +1992,7 @@ static void TestGeneralizeRepresentationWithSpecialTransition( ...@@ -2016,7 +1992,7 @@ static void TestGeneralizeRepresentationWithSpecialTransition(
// In case of non-equivalent transition currently we generalize all // In case of non-equivalent transition currently we generalize all
// representations. // representations.
for (int i = 0; i < kPropCount; i++) { for (int i = 0; i < kPropCount; i++) {
expectations2.GeneralizeRepresentation(i); expectations2.GeneralizeField(i);
} }
CHECK(new_map2->GetBackPointer()->IsUndefined(isolate)); CHECK(new_map2->GetBackPointer()->IsUndefined(isolate));
CHECK(expectations2.Check(*new_map2)); CHECK(expectations2.Check(*new_map2));
...@@ -2059,7 +2035,7 @@ TEST(ElementsKindTransitionFromMapOwningDescriptor) { ...@@ -2059,7 +2035,7 @@ TEST(ElementsKindTransitionFromMapOwningDescriptor) {
bool is_non_equevalent_transition() const { return true; } bool is_non_equevalent_transition() const { return true; }
}; };
TestConfig config; TestConfig config;
TestGeneralizeRepresentationWithSpecialTransition( TestGeneralizeFieldWithSpecialTransition(
config, {kMutable, Representation::Smi(), any_type}, config, {kMutable, Representation::Smi(), any_type},
{kMutable, Representation::HeapObject(), value_type}, {kMutable, Representation::HeapObject(), value_type},
{kMutable, Representation::Tagged(), any_type}); {kMutable, Representation::Tagged(), any_type});
...@@ -2097,7 +2073,7 @@ TEST(ElementsKindTransitionFromMapNotOwningDescriptor) { ...@@ -2097,7 +2073,7 @@ TEST(ElementsKindTransitionFromMapNotOwningDescriptor) {
bool is_non_equevalent_transition() const { return true; } bool is_non_equevalent_transition() const { return true; }
}; };
TestConfig config; TestConfig config;
TestGeneralizeRepresentationWithSpecialTransition( TestGeneralizeFieldWithSpecialTransition(
config, {kMutable, Representation::Smi(), any_type}, config, {kMutable, Representation::Smi(), any_type},
{kMutable, Representation::HeapObject(), value_type}, {kMutable, Representation::HeapObject(), value_type},
{kMutable, Representation::Tagged(), any_type}); {kMutable, Representation::Tagged(), any_type});
...@@ -2132,7 +2108,7 @@ TEST(PrototypeTransitionFromMapOwningDescriptor) { ...@@ -2132,7 +2108,7 @@ TEST(PrototypeTransitionFromMapOwningDescriptor) {
bool is_non_equevalent_transition() const { return true; } bool is_non_equevalent_transition() const { return true; }
}; };
TestConfig config; TestConfig config;
TestGeneralizeRepresentationWithSpecialTransition( TestGeneralizeFieldWithSpecialTransition(
config, {kMutable, Representation::Smi(), any_type}, config, {kMutable, Representation::Smi(), any_type},
{kMutable, Representation::HeapObject(), value_type}, {kMutable, Representation::HeapObject(), value_type},
{kMutable, Representation::Tagged(), any_type}); {kMutable, Representation::Tagged(), any_type});
...@@ -2178,7 +2154,7 @@ TEST(PrototypeTransitionFromMapNotOwningDescriptor) { ...@@ -2178,7 +2154,7 @@ TEST(PrototypeTransitionFromMapNotOwningDescriptor) {
bool is_non_equevalent_transition() const { return true; } bool is_non_equevalent_transition() const { return true; }
}; };
TestConfig config; TestConfig config;
TestGeneralizeRepresentationWithSpecialTransition( TestGeneralizeFieldWithSpecialTransition(
config, {kMutable, Representation::Smi(), any_type}, config, {kMutable, Representation::Smi(), any_type},
{kMutable, Representation::HeapObject(), value_type}, {kMutable, Representation::HeapObject(), value_type},
{kMutable, Representation::Tagged(), any_type}); {kMutable, Representation::Tagged(), any_type});
...@@ -2281,8 +2257,7 @@ struct ReconfigureAsAccessorPropertyOperator { ...@@ -2281,8 +2257,7 @@ struct ReconfigureAsAccessorPropertyOperator {
} }
}; };
// Checks that field generalization happened.
// Checks that representation/field type generalization happened.
struct FieldGeneralizationChecker { struct FieldGeneralizationChecker {
int descriptor_; int descriptor_;
PropertyConstness constness_; PropertyConstness constness_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment