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

Unified Diff: src/objects.cc

Issue 1094313003: Revert of track global accesses to constant types (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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/objects.h ('k') | src/property-details.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 0cd8b71a77dcd83161c8ed35d526a7a5cdb325c4..f57c569d09b36bf08bcdab3288dd552b85b960c6 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -1786,7 +1786,7 @@
DCHECK(!object->HasFastProperties());
Isolate* isolate = object->GetIsolate();
Handle<NameDictionary> dict(object->property_dictionary());
- PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
+ PropertyDetails details(attributes, DATA, 0, PropertyCellType::kInvalid);
if (object->IsGlobalObject()) {
int entry = dict->FindEntry(name);
// If there's a cell there, just invalidate and set the property.
@@ -4592,7 +4592,7 @@
case DATA_CONSTANT: {
Handle<Object> value(descs->GetConstant(i), isolate);
PropertyDetails d(details.attributes(), DATA, i + 1,
- PropertyCellType::kNoCell);
+ PropertyCellType::kInvalid);
dictionary = NameDictionary::Add(dictionary, key, value, d);
break;
}
@@ -4611,7 +4611,7 @@
}
}
PropertyDetails d(details.attributes(), DATA, i + 1,
- PropertyCellType::kNoCell);
+ PropertyCellType::kInvalid);
dictionary = NameDictionary::Add(dictionary, key, value, d);
break;
}
@@ -4619,14 +4619,14 @@
FieldIndex index = FieldIndex::ForDescriptor(*map, i);
Handle<Object> value(object->RawFastPropertyAt(index), isolate);
PropertyDetails d(details.attributes(), ACCESSOR_CONSTANT, i + 1,
- PropertyCellType::kNoCell);
+ PropertyCellType::kInvalid);
dictionary = NameDictionary::Add(dictionary, key, value, d);
break;
}
case ACCESSOR_CONSTANT: {
Handle<Object> value(descs->GetCallbacksObject(i), isolate);
PropertyDetails d(details.attributes(), ACCESSOR_CONSTANT, i + 1,
- PropertyCellType::kNoCell);
+ PropertyCellType::kInvalid);
dictionary = NameDictionary::Add(dictionary, key, value, d);
break;
}
@@ -5351,7 +5351,7 @@
cell->set_value(isolate->heap()->the_hole_value());
// TODO(dcarney): InvalidateForDelete
dictionary->DetailsAtPut(entry, dictionary->DetailsAt(entry).set_cell_type(
- PropertyCellType::kInvalidated));
+ PropertyCellType::kDeleted));
return;
}
@@ -6425,7 +6425,7 @@
if (details.attributes() != attributes) {
dictionary->DetailsAtPut(
entry, PropertyDetails(attributes, ACCESSOR_CONSTANT, index,
- PropertyCellType::kNoCell));
+ PropertyCellType::kInvalid));
}
AccessorPair::cast(result)->SetComponents(getter, setter);
return true;
@@ -6528,7 +6528,7 @@
PropertyAttributes attributes) {
Heap* heap = object->GetHeap();
PropertyDetails details = PropertyDetails(attributes, ACCESSOR_CONSTANT, 0,
- PropertyCellType::kNoCell);
+ PropertyCellType::kInvalid);
// Normalize elements to make this operation simple.
bool had_dictionary_elements = object->HasDictionaryElements();
@@ -12891,7 +12891,7 @@
dictionary->UpdateMaxNumberKey(index);
if (set_mode == DEFINE_PROPERTY) {
details = PropertyDetails(attributes, DATA, details.dictionary_index(),
- PropertyCellType::kNoCell);
+ PropertyCellType::kInvalid);
dictionary->DetailsAtPut(entry, details);
}
@@ -12934,7 +12934,7 @@
}
}
- PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
+ PropertyDetails details(attributes, DATA, 0, PropertyCellType::kInvalid);
Handle<SeededNumberDictionary> new_dictionary =
SeededNumberDictionary::AddNumberEntry(dictionary, index, value,
details);
@@ -15366,7 +15366,7 @@
DCHECK(dictionary->DetailsAt(entry).cell_type() ==
PropertyCellType::kUninitialized ||
dictionary->DetailsAt(entry).cell_type() ==
- PropertyCellType::kInvalidated);
+ PropertyCellType::kDeleted);
DCHECK(dictionary->ValueAt(entry)->IsPropertyCell());
cell = handle(PropertyCell::cast(dictionary->ValueAt(entry)));
DCHECK(cell->value()->IsTheHole());
@@ -17001,7 +17001,7 @@
bool is_the_hole = cell->value()->IsTheHole();
// Cell is officially mutable henceforth.
auto details = dictionary->DetailsAt(entry);
- details = details.set_cell_type(is_the_hole ? PropertyCellType::kInvalidated
+ details = details.set_cell_type(is_the_hole ? PropertyCellType::kDeleted
: PropertyCellType::kMutable);
dictionary->DetailsAtPut(entry, details);
// Old cell is ready for invalidation.
@@ -17016,54 +17016,24 @@
}
-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
- 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();
- }
- return false;
-}
-
-
PropertyCellType PropertyCell::UpdatedType(Handle<PropertyCell> cell,
Handle<Object> value,
PropertyDetails details) {
PropertyCellType type = details.cell_type();
DCHECK(!value->IsTheHole());
- if (cell->value()->IsTheHole()) {
- switch (type) {
- // Only allow a cell to transition once into constant state.
- case PropertyCellType::kUninitialized:
- if (value->IsUndefined()) return PropertyCellType::kUndefined;
- return PropertyCellType::kConstant;
- case PropertyCellType::kInvalidated:
- return PropertyCellType::kMutable;
- default:
- UNREACHABLE();
- return PropertyCellType::kMutable;
- }
- }
+ DCHECK_IMPLIES(cell->value()->IsTheHole(),
+ type == PropertyCellType::kUninitialized ||
+ type == PropertyCellType::kDeleted);
switch (type) {
+ // Only allow a cell to transition once into constant state.
+ case PropertyCellType::kUninitialized:
+ if (value->IsUndefined()) return PropertyCellType::kUndefined;
+ return PropertyCellType::kConstant;
case PropertyCellType::kUndefined:
return PropertyCellType::kConstant;
case PropertyCellType::kConstant:
+ // No transition.
if (*value == cell->value()) return PropertyCellType::kConstant;
- // Fall through.
- case PropertyCellType::kConstantType:
- if (RemainsConstantType(cell, value)) {
- return PropertyCellType::kConstantType;
- }
// Fall through.
case PropertyCellType::kMutable:
return PropertyCellType::kMutable;
@@ -17117,7 +17087,8 @@
cell->set_value(*value);
// Deopt when transitioning from a constant type.
- if (!invalidate && (old_type != new_type)) {
+ if (!invalidate && old_type == PropertyCellType::kConstant &&
+ new_type != PropertyCellType::kConstant) {
auto isolate = dictionary->GetIsolate();
cell->dependent_code()->DeoptimizeDependentCodeGroup(
isolate, DependentCode::kPropertyCellChangedGroup);
« no previous file with comments | « src/objects.h ('k') | src/property-details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698