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

Unified Diff: test/cctest/test-field-type-tracking.cc

Issue 2629423002: [runtime] Remove PropertyType definition and use PropertyKind/PropertyLocation instead. (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/property-details.h ('k') | test/cctest/test-transitions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-field-type-tracking.cc
diff --git a/test/cctest/test-field-type-tracking.cc b/test/cctest/test-field-type-tracking.cc
index 7023dfce9a4178ac9c3fbd98e6d5e1651ce14ff0..08248ecf4db20e57e0ea8a81ae66f83f9cecbccf 100644
--- a/test/cctest/test-field-type-tracking.cc
+++ b/test/cctest/test-field-type-tracking.cc
@@ -73,23 +73,12 @@ static Handle<AccessorPair> CreateAccessorPair(bool with_getter,
}
-static bool EqualDetails(DescriptorArray* descriptors, int descriptor,
- PropertyType type, PropertyAttributes attributes,
- Representation representation, int field_index = -1) {
- PropertyDetails details = descriptors->GetDetails(descriptor);
- if (details.type() != type) return false;
- if (details.attributes() != attributes) return false;
- if (!details.representation().Equals(representation)) return false;
- if (field_index >= 0 && details.field_index() != field_index) return false;
- return true;
-}
-
-
class Expectations {
static const int MAX_PROPERTIES = 10;
Isolate* isolate_;
ElementsKind elements_kind_;
- PropertyType types_[MAX_PROPERTIES];
+ PropertyKind kinds_[MAX_PROPERTIES];
+ PropertyLocation locations_[MAX_PROPERTIES];
PropertyAttributes attributes_[MAX_PROPERTIES];
Representation representations_[MAX_PROPERTIES];
// FieldType for kField, value for DATA_CONSTANT and getter for
@@ -110,10 +99,12 @@ class Expectations {
isolate,
isolate->object_function()->initial_map()->elements_kind()) {}
- void Init(int index, PropertyType type, PropertyAttributes attributes,
- Representation representation, Handle<Object> value) {
+ void Init(int index, PropertyKind kind, PropertyAttributes attributes,
+ PropertyLocation location, Representation representation,
+ Handle<Object> value) {
CHECK(index < MAX_PROPERTIES);
- types_[index] = type;
+ kinds_[index] = kind;
+ locations_[index] = location;
attributes_[index] = attributes;
representations_[index] = representation;
values_[index] = value;
@@ -125,29 +116,23 @@ class Expectations {
for (int i = 0; i < number_of_properties_; i++) {
os << " " << i << ": ";
os << "Descriptor @ ";
- if (types_[i] == ACCESSOR_CONSTANT) {
+
+ if (kinds_[i] == kData) {
+ os << Brief(*values_[i]);
+ } else {
+ // kAccessor
os << "(get: " << Brief(*values_[i])
<< ", set: " << Brief(*setter_values_[i]) << ") ";
- } else {
- os << Brief(*values_[i]);
}
+
os << " (";
- switch (types_[i]) {
- case DATA_CONSTANT:
- os << "immutable ";
- // Fall through.
- case DATA:
- os << "data";
- break;
-
- case ACCESSOR_CONSTANT:
- os << "immutable ";
- // Fall through.
- case ACCESSOR:
- os << "accessor";
- break;
+ os << (kinds_[i] == kData ? "data " : "accessor ");
+ if (locations_[i] == kField) {
+ os << "field"
+ << ": " << representations_[i].Mnemonic();
+ } else {
+ os << "descriptor";
}
- os << ": " << representations_[i].Mnemonic();
os << ", attrs: " << attributes_[i] << ")\n";
}
os << "\n";
@@ -159,22 +144,23 @@ class Expectations {
Handle<FieldType> GetFieldType(int index) {
CHECK(index < MAX_PROPERTIES);
- CHECK(types_[index] == DATA || types_[index] == ACCESSOR);
+ CHECK_EQ(kField, locations_[index]);
return Handle<FieldType>::cast(values_[index]);
}
void SetDataField(int index, PropertyAttributes attrs,
- Representation representation, Handle<FieldType> value) {
- Init(index, DATA, attrs, representation, value);
+ Representation representation,
+ Handle<FieldType> field_type) {
+ Init(index, kData, attrs, kField, representation, field_type);
}
void SetDataField(int index, Representation representation,
- Handle<FieldType> value) {
- SetDataField(index, attributes_[index], representation, value);
+ Handle<FieldType> field_type) {
+ SetDataField(index, attributes_[index], representation, field_type);
}
void SetAccessorField(int index, PropertyAttributes attrs) {
- Init(index, ACCESSOR, attrs, Representation::Tagged(),
+ Init(index, kAccessor, attrs, kDescriptor, Representation::Tagged(),
FieldType::Any(isolate_));
}
@@ -184,7 +170,7 @@ class Expectations {
void SetDataConstant(int index, PropertyAttributes attrs,
Handle<JSFunction> value) {
- Init(index, DATA_CONSTANT, attrs, Representation::HeapObject(), value);
+ Init(index, kData, attrs, kDescriptor, Representation::HeapObject(), value);
}
void SetDataConstant(int index, Handle<JSFunction> value) {
@@ -193,14 +179,16 @@ class Expectations {
void SetAccessorConstant(int index, PropertyAttributes attrs,
Handle<Object> getter, Handle<Object> setter) {
- Init(index, ACCESSOR_CONSTANT, attrs, Representation::Tagged(), getter);
+ Init(index, kAccessor, attrs, kDescriptor, Representation::Tagged(),
+ getter);
setter_values_[index] = setter;
}
void SetAccessorConstantComponent(int index, PropertyAttributes attrs,
AccessorComponent component,
Handle<Object> accessor) {
- CHECK_EQ(ACCESSOR_CONSTANT, types_[index]);
+ CHECK_EQ(kAccessor, kinds_[index]);
+ CHECK_EQ(kDescriptor, locations_[index]);
CHECK(index < number_of_properties_);
if (component == ACCESSOR_GETTER) {
values_[index] = accessor;
@@ -230,31 +218,41 @@ class Expectations {
void GeneralizeRepresentation(int index) {
CHECK(index < number_of_properties_);
representations_[index] = Representation::Tagged();
- if (types_[index] == DATA || types_[index] == ACCESSOR) {
+ if (locations_[index] == kField) {
values_[index] = FieldType::Any(isolate_);
}
}
bool Check(DescriptorArray* descriptors, int descriptor) const {
- PropertyType type = types_[descriptor];
- if (!EqualDetails(descriptors, descriptor, type, attributes_[descriptor],
- representations_[descriptor])) {
- return false;
- }
+ PropertyDetails details = descriptors->GetDetails(descriptor);
+
+ if (details.kind() != kinds_[descriptor]) return false;
+ if (details.location() != locations_[descriptor]) return false;
+
+ PropertyAttributes expected_attributes = attributes_[descriptor];
+ if (details.attributes() != expected_attributes) return false;
+
+ Representation expected_representation = representations_[descriptor];
+ if (!details.representation().Equals(expected_representation)) return false;
+
Object* value = descriptors->GetValue(descriptor);
Object* expected_value = *values_[descriptor];
- switch (type) {
- case DATA:
- case ACCESSOR: {
+ if (details.location() == kField) {
+ if (details.kind() == kData) {
FieldType* type = descriptors->GetFieldType(descriptor);
return FieldType::cast(expected_value) == type;
+ } else {
+ // kAccessor
+ UNREACHABLE();
+ return false;
}
-
- case DATA_CONSTANT:
+ } else {
+ // kDescriptor
+ if (details.kind() == kData) {
return value == expected_value;
-
- case ACCESSOR_CONSTANT: {
+ } else {
+ // kAccessor
if (value == expected_value) return true;
if (!value->IsAccessorPair()) return false;
AccessorPair* pair = AccessorPair::cast(value);
« no previous file with comments | « src/property-details.h ('k') | test/cctest/test-transitions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698