[runtime] Avoid handles in PropertyCell-related code
Bug: v8:11263 Change-Id: I02c51fae400a9a5d67376ed645ea01be4ef1dc1e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3417437 Reviewed-by: Igor Sheludko <ishell@chromium.org> Commit-Queue: Camillo Bruni <cbruni@chromium.org> Cr-Commit-Position: refs/heads/main@{#78810}
This commit is contained in:
parent
2775ad6362
commit
9f4f472b33
@ -587,7 +587,7 @@ void LookupIterator::PrepareTransitionToDataProperty(
|
||||
// Don't set enumeration index (it will be set during value store).
|
||||
property_details_ =
|
||||
PropertyDetails(PropertyKind::kData, attributes,
|
||||
PropertyCell::InitialType(isolate_, value));
|
||||
PropertyCell::InitialType(isolate_, *value));
|
||||
transition_ = isolate_->factory()->NewPropertyCell(
|
||||
name(), property_details_, value);
|
||||
has_property_ = true;
|
||||
|
@ -6516,38 +6516,36 @@ Handle<PropertyCell> PropertyCell::InvalidateAndReplaceEntry(
|
||||
return new_cell;
|
||||
}
|
||||
|
||||
static bool RemainsConstantType(Handle<PropertyCell> cell,
|
||||
Handle<Object> value) {
|
||||
static bool RemainsConstantType(PropertyCell cell, Object value) {
|
||||
DisallowGarbageCollection no_gc;
|
||||
// TODO(dcarney): double->smi and smi->double transition from kConstant
|
||||
if (cell->value().IsSmi() && value->IsSmi()) {
|
||||
if (cell.value().IsSmi() && value.IsSmi()) {
|
||||
return true;
|
||||
} else if (cell->value().IsHeapObject() && value->IsHeapObject()) {
|
||||
return HeapObject::cast(cell->value()).map() ==
|
||||
HeapObject::cast(*value).map() &&
|
||||
HeapObject::cast(*value).map().is_stable();
|
||||
} else if (cell.value().IsHeapObject() && value.IsHeapObject()) {
|
||||
Map map = HeapObject::cast(value).map();
|
||||
return HeapObject::cast(cell.value()).map() == map && map.is_stable();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
PropertyCellType PropertyCell::InitialType(Isolate* isolate,
|
||||
Handle<Object> value) {
|
||||
return value->IsUndefined(isolate) ? PropertyCellType::kUndefined
|
||||
: PropertyCellType::kConstant;
|
||||
PropertyCellType PropertyCell::InitialType(Isolate* isolate, Object value) {
|
||||
return value.IsUndefined(isolate) ? PropertyCellType::kUndefined
|
||||
: PropertyCellType::kConstant;
|
||||
}
|
||||
|
||||
// static
|
||||
PropertyCellType PropertyCell::UpdatedType(Isolate* isolate,
|
||||
Handle<PropertyCell> cell,
|
||||
Handle<Object> value,
|
||||
PropertyCellType PropertyCell::UpdatedType(Isolate* isolate, PropertyCell cell,
|
||||
Object value,
|
||||
PropertyDetails details) {
|
||||
DCHECK(!value->IsTheHole(isolate));
|
||||
DCHECK(!cell->value().IsTheHole(isolate));
|
||||
DisallowGarbageCollection no_gc;
|
||||
DCHECK(!value.IsTheHole(isolate));
|
||||
DCHECK(!cell.value().IsTheHole(isolate));
|
||||
switch (details.cell_type()) {
|
||||
case PropertyCellType::kUndefined:
|
||||
return PropertyCellType::kConstant;
|
||||
case PropertyCellType::kConstant:
|
||||
if (*value == cell->value()) return PropertyCellType::kConstant;
|
||||
if (value == cell.value()) return PropertyCellType::kConstant;
|
||||
V8_FALLTHROUGH;
|
||||
case PropertyCellType::kConstantType:
|
||||
if (RemainsConstantType(cell, value)) {
|
||||
@ -6565,9 +6563,9 @@ Handle<PropertyCell> PropertyCell::PrepareForAndSetValue(
|
||||
Isolate* isolate, Handle<GlobalDictionary> dictionary, InternalIndex entry,
|
||||
Handle<Object> value, PropertyDetails details) {
|
||||
DCHECK(!value->IsTheHole(isolate));
|
||||
Handle<PropertyCell> cell(dictionary->CellAt(entry), isolate);
|
||||
CHECK(!cell->value().IsTheHole(isolate));
|
||||
const PropertyDetails original_details = cell->property_details();
|
||||
PropertyCell raw_cell = dictionary->CellAt(entry);
|
||||
CHECK(!raw_cell.value().IsTheHole(isolate));
|
||||
const PropertyDetails original_details = raw_cell.property_details();
|
||||
// Data accesses could be cached in ics or optimized code.
|
||||
bool invalidate = original_details.kind() == PropertyKind::kData &&
|
||||
details.kind() == PropertyKind::kAccessor;
|
||||
@ -6576,9 +6574,11 @@ Handle<PropertyCell> PropertyCell::PrepareForAndSetValue(
|
||||
details = details.set_index(index);
|
||||
|
||||
PropertyCellType new_type =
|
||||
UpdatedType(isolate, cell, value, original_details);
|
||||
UpdatedType(isolate, raw_cell, *value, original_details);
|
||||
details = details.set_cell_type(new_type);
|
||||
|
||||
Handle<PropertyCell> cell(raw_cell, isolate);
|
||||
|
||||
if (invalidate) {
|
||||
cell = PropertyCell::InvalidateAndReplaceEntry(isolate, dictionary, entry,
|
||||
details, value);
|
||||
|
@ -41,14 +41,12 @@ class PropertyCell
|
||||
// For protectors:
|
||||
void InvalidateProtector();
|
||||
|
||||
static PropertyCellType InitialType(Isolate* isolate, Handle<Object> value);
|
||||
static PropertyCellType InitialType(Isolate* isolate, 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,
|
||||
Handle<PropertyCell> cell,
|
||||
Handle<Object> value,
|
||||
PropertyDetails details);
|
||||
static PropertyCellType UpdatedType(Isolate* isolate, PropertyCell cell,
|
||||
Object value, PropertyDetails details);
|
||||
|
||||
// Prepares property cell at given entry for receiving given value and sets
|
||||
// that value. As a result the old cell could be invalidated and/or dependent
|
||||
|
@ -1788,7 +1788,7 @@ void WebSnapshotDeserializer::DeserializeExports() {
|
||||
|
||||
PropertyDetails property_details =
|
||||
PropertyDetails(PropertyKind::kData, NONE,
|
||||
PropertyCell::InitialType(isolate_, export_value));
|
||||
PropertyCell::InitialType(isolate_, *export_value));
|
||||
Handle<PropertyCell> transition_cell = isolate_->factory()->NewPropertyCell(
|
||||
export_name, property_details, export_value);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user