Commit 3728728d authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[runtime] Yet another PropertyCell cleanup

Main changes:

- Remove the kUninitialized and kInvalidated cell type aliases. They
  were confusing because their meaning depended on the current value in
  the cell. I think kUninitialized was obsolete anyways.
- Remove a DCHECK from the compiler. The property that was asserted,
  while true, is irrelevant.
- Remove the obsolete function GetConstantType. The only left use was
  in the object printer, but it's pointless there because we already
  print the value anyways.

Change-Id: Ic718c8ba39aeb5bf18f588535dfb755a023cb144
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2536647Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71198}
parent df842562
......@@ -270,8 +270,6 @@ class GlobalPropertyDependency final : public CompilationDependency {
// The dependency is never valid if the cell is 'invalidated'. This is
// marked by setting the value to the hole.
if (cell->value() == *(cell_.isolate()->factory()->the_hole_value())) {
DCHECK_EQ(cell->property_details().cell_type(),
PropertyCellType::kInvalidated);
return false;
}
return type_ == cell->property_details().cell_type() &&
......
......@@ -1513,45 +1513,7 @@ void PropertyCell::PropertyCellPrint(std::ostream& os) { // NOLINT
os << "\n - details: ";
property_details().PrintAsSlowTo(os, true);
PropertyCellType cell_type = property_details().cell_type();
os << "\n - cell_type: ";
if (value().IsTheHole()) {
switch (cell_type) {
case PropertyCellType::kUninitialized:
os << "Uninitialized";
break;
case PropertyCellType::kInvalidated:
os << "Invalidated";
break;
default:
os << "??? " << static_cast<int>(cell_type);
break;
}
} else {
switch (cell_type) {
case PropertyCellType::kUndefined:
os << "Undefined";
break;
case PropertyCellType::kConstant:
os << "Constant";
break;
case PropertyCellType::kConstantType:
os << "ConstantType"
<< " (";
switch (GetConstantType()) {
case PropertyCellConstantType::kSmi:
os << "Smi";
break;
case PropertyCellConstantType::kStableMap:
os << "StableMap";
break;
}
os << ")";
break;
case PropertyCellType::kMutable:
os << "Mutable";
break;
}
}
os << "\n - cell_type: " << cell_type;
os << "\n";
}
......
......@@ -575,9 +575,7 @@ void LookupIterator::PrepareTransitionToDataProperty(
DCHECK(!value->IsTheHole(isolate_));
// Don't set enumeration index (it will be set during value store).
property_details_ = PropertyDetails(
kData, attributes,
PropertyCell::TypeForUninitializedCell(isolate_, value));
kData, attributes, PropertyCell::InitialType(isolate_, value));
transition_ = cell;
has_property_ = true;
} else {
......
......@@ -184,6 +184,20 @@ std::ostream& operator<<(std::ostream& os, InstanceType instance_type) {
UNREACHABLE();
}
std::ostream& operator<<(std::ostream& os, PropertyCellType type) {
switch (type) {
case PropertyCellType::kUndefined:
return os << "Undefined";
case PropertyCellType::kConstant:
return os << "Constant";
case PropertyCellType::kConstantType:
return os << "ConstantType";
case PropertyCellType::kMutable:
return os << "Mutable";
}
UNREACHABLE();
}
Handle<FieldType> Object::OptimalType(Isolate* isolate,
Representation representation) {
if (representation.IsNone()) return FieldType::None(isolate);
......@@ -6331,10 +6345,9 @@ Handle<JSArray> JSWeakCollection::GetEntries(Handle<JSWeakCollection> holder,
}
void PropertyCell::ClearAndInvalidate(ReadOnlyRoots roots) {
// Cell is officially mutable henceforth.
DCHECK(!value().IsTheHole(roots));
PropertyDetails details = property_details();
details = details.set_cell_type(PropertyCellType::kInvalidated);
details = details.set_cell_type(PropertyCellType::kConstant);
set_value(roots.the_hole_value());
set_property_details(details);
dependent_code().DeoptimizeDependentCodeGroup(
......@@ -6363,11 +6376,6 @@ Handle<PropertyCell> PropertyCell::InvalidateAndReplaceEntry(
return new_cell;
}
PropertyCellConstantType PropertyCell::GetConstantType() {
if (value().IsSmi()) return PropertyCellConstantType::kSmi;
return PropertyCellConstantType::kStableMap;
}
static bool RemainsConstantType(Handle<PropertyCell> cell,
Handle<Object> value) {
// TODO(dcarney): double->smi and smi->double transition from kConstant
......@@ -6382,10 +6390,10 @@ static bool RemainsConstantType(Handle<PropertyCell> cell,
}
// static
PropertyCellType PropertyCell::TypeForUninitializedCell(Isolate* isolate,
Handle<Object> value) {
if (value->IsUndefined(isolate)) return PropertyCellType::kUndefined;
return PropertyCellType::kConstant;
PropertyCellType PropertyCell::InitialType(Isolate* isolate,
Handle<Object> value) {
return value->IsUndefined(isolate) ? PropertyCellType::kUndefined
: PropertyCellType::kConstant;
}
// static
......
......@@ -19,6 +19,7 @@ namespace internal {
OBJECT_CONSTRUCTORS_IMPL(PropertyCell, HeapObject)
CAST_ACCESSOR(PropertyCell)
ACCESSORS(PropertyCell, dependent_code, DependentCode, kDependentCodeOffset)
ACCESSORS(PropertyCell, name, Name, kNameOffset)
ACCESSORS(PropertyCell, value, Object, kValueOffset)
......
......@@ -18,23 +18,21 @@ class PropertyCell : public HeapObject {
public:
// [name]: the name of the global property.
DECL_GETTER(name, Name)
// [property_details]: details of the global property.
DECL_ACCESSORS(property_details_raw, Smi)
// [value]: value of the global property.
DECL_ACCESSORS(value, Object)
// [dependent_code]: dependent code that depends on the type of the global
// property.
// [dependent_code]: code that depends on the type of the global property.
DECL_ACCESSORS(dependent_code, DependentCode)
inline PropertyDetails property_details() const;
inline void set_property_details(PropertyDetails details);
PropertyCellConstantType GetConstantType();
static PropertyCellType InitialType(Isolate* isolate, Handle<Object> value);
// Computes the new type of a previously uninitialized cell for the given
// value.
static PropertyCellType TypeForUninitializedCell(Isolate* isolate,
Handle<Object> value);
// Computes the new type of the cell's contents for the given value, but
// without actually modifying the details.
static PropertyCellType UpdatedType(Isolate* isolate,
......@@ -59,8 +57,6 @@ class PropertyCell : public HeapObject {
Handle<Object> new_value);
DECL_CAST(PropertyCell)
// Dispatched behavior.
DECL_PRINTER(PropertyCell)
DECL_VERIFIER(PropertyCell)
......
......@@ -207,26 +207,18 @@ static const int kMaxNumberOfDescriptors = (1 << kDescriptorIndexBitCount) - 4;
static const int kInvalidEnumCacheSentinel =
(1 << kDescriptorIndexBitCount) - 1;
// A PropertyCell's property details contains a cell type that is meaningful if
// the cell is still valid (does not hold the hole).
enum class PropertyCellType {
// Meaningful when a property cell does not contain the hole.
kUndefined, // The PREMONOMORPHIC of property cells.
kConstant, // Cell has been assigned only once.
kConstantType, // Cell has been assigned only one type.
kMutable, // Cell will no longer be tracked as constant.
// Meaningful when a property cell contains the hole.
kUninitialized = kUndefined, // Cell has never been initialized.
kInvalidated = kConstant, // Cell has been deleted, invalidated or never
// existed.
// For dictionaries not holding cells.
// Arbitrary choice for dictionaries not holding cells.
kNoCell = kMutable,
};
enum class PropertyCellConstantType {
kSmi,
kStableMap,
};
std::ostream& operator<<(std::ostream& os, PropertyCellType type);
// PropertyDetails captures type and attributes for a property.
// They are used both in property dictionaries and instance descriptors.
......
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