Commit e784719b authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[cleanup] Remove dead TransitionAccessor::Encoding::kHandler + related code.

This is also pre-work for in-place weak refs.

BUG=v8:7308, v8:5988

Change-Id: Ie78b0c59695c1e6af9780fffb363c931e2ee34e2
Reviewed-on: https://chromium-review.googlesource.com/1013583
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52658}
parent 24cfa03d
......@@ -187,14 +187,6 @@ Handle<Smi> StoreHandler::StoreApiSetter(Isolate* isolate,
return handle(Smi::FromInt(config), isolate);
}
// static
WeakCell* StoreHandler::GetTransitionCell(Object* handler) {
DCHECK(handler->IsStoreHandler());
WeakCell* cell = WeakCell::cast(StoreHandler::cast(handler)->data1());
DCHECK(!cell->cleared());
return cell;
}
} // namespace internal
} // namespace v8
......
......@@ -287,35 +287,5 @@ Handle<Object> StoreHandler::StoreProxy(Isolate* isolate,
holder_cell);
}
Object* StoreHandler::ValidHandlerOrNull(Object* raw_handler, Name* name,
Handle<Map>* out_transition) {
Smi* valid = Smi::FromInt(Map::kPrototypeChainValid);
DCHECK(raw_handler->IsStoreHandler());
// Check validity cell.
StoreHandler* handler = StoreHandler::cast(raw_handler);
Object* raw_validity_cell = handler->validity_cell();
// |raw_valitity_cell| can be Smi::kZero if no validity cell is required
// (which counts as valid).
if (raw_validity_cell->IsCell() &&
Cell::cast(raw_validity_cell)->value() != valid) {
return nullptr;
}
// We use this ValidHandlerOrNull() function only for transitioning store
// handlers which are not applicable to receivers that require access checks.
DCHECK(handler->smi_handler()->IsSmi());
DCHECK(
!DoAccessCheckOnReceiverBits::decode(Smi::ToInt(handler->smi_handler())));
// Check if the transition target is deprecated.
WeakCell* target_cell = GetTransitionCell(raw_handler);
Map* transition = Map::cast(target_cell->value());
if (transition->is_deprecated()) return nullptr;
*out_transition = handle(transition);
return raw_handler;
}
} // namespace internal
} // namespace v8
......@@ -243,10 +243,6 @@ class StoreHandler final : public DataHandler {
// Make sure we don't overflow the smi.
STATIC_ASSERT(FieldIndexBits::kNext <= kSmiValueSize);
static inline WeakCell* GetTransitionCell(Object* handler);
static Object* ValidHandlerOrNull(Object* handler, Name* name,
Handle<Map>* out_transition);
// Creates a Smi-handler for storing a field to fast object.
static inline Handle<Smi> StoreField(Isolate* isolate, int descriptor,
FieldIndex field_index,
......
......@@ -2024,7 +2024,7 @@ void DescriptorArray::Print() {
}
// static
void TransitionsAccessor::PrintOneTransition(std::ostream& os, Name* key,
Map* target, Object* raw_target) {
Map* target) {
os << "\n ";
#ifdef OBJECT_PRINT
key->NamePrint(os);
......@@ -2054,9 +2054,6 @@ void TransitionsAccessor::PrintOneTransition(std::ostream& os, Name* key,
os << ")";
}
os << " -> " << Brief(target);
if (!raw_target->IsMap() && !raw_target->IsWeakCell()) {
os << " (handler: " << Brief(raw_target) << ")";
}
}
void TransitionArray::Print() {
......@@ -2071,32 +2068,25 @@ void TransitionArray::Print(std::ostream& os) {
for (int i = 0; i < num_transitions; i++) {
Name* key = GetKey(i);
Map* target = GetTarget(i);
Object* raw_target = GetRawTarget(i);
TransitionsAccessor::PrintOneTransition(os, key, target, raw_target);
TransitionsAccessor::PrintOneTransition(os, key, target);
}
os << "\n" << std::flush;
}
void TransitionsAccessor::PrintTransitions(std::ostream& os) { // NOLINT
Map* target;
switch (encoding()) {
case kPrototypeInfo:
case kUninitialized:
return;
case kWeakRef:
target = Map::cast(raw_transitions_->ToWeakHeapObject());
break;
case kHandler: {
WeakCell* cell = GetTargetCell();
DCHECK(!cell->cleared());
target = Map::cast(cell->value());
case kWeakRef: {
Map* target = Map::cast(raw_transitions_->ToWeakHeapObject());
Name* key = GetSimpleTransitionKey(target);
PrintOneTransition(os, key, target);
break;
}
case kFullTransitionArray:
return transitions()->Print(os);
}
Name* key = GetSimpleTransitionKey(target);
PrintOneTransition(os, key, target, raw_transitions_->GetHeapObject());
}
void TransitionsAccessor::PrintTransitionTree() {
......
......@@ -15,15 +15,6 @@
namespace v8 {
namespace internal {
WeakCell* TransitionsAccessor::GetTargetCell() {
DCHECK(!needs_reload_);
if (target_cell_ == nullptr) {
target_cell_ =
StoreHandler::GetTransitionCell(raw_transitions_->ToStrongHeapObject());
}
return target_cell_;
}
TransitionArray* TransitionsAccessor::transitions() {
DCHECK_EQ(kFullTransitionArray, encoding());
return TransitionArray::cast(raw_transitions_->ToStrongHeapObject());
......@@ -66,25 +57,19 @@ Name* TransitionArray::GetKey(int transition_number) {
}
Name* TransitionsAccessor::GetKey(int transition_number) {
Map* map = nullptr;
switch (encoding()) {
case kPrototypeInfo:
case kUninitialized:
UNREACHABLE();
return nullptr;
case kWeakRef:
map = Map::cast(raw_transitions_->ToWeakHeapObject());
break;
case kHandler: {
WeakCell* cell = GetTargetCell();
DCHECK(!cell->cleared());
map = Map::cast(cell->value());
break;
case kWeakRef: {
Map* map = Map::cast(raw_transitions_->ToWeakHeapObject());
return GetSimpleTransitionKey(map);
}
case kFullTransitionArray:
return transitions()->GetKey(transition_number);
}
return GetSimpleTransitionKey(map);
UNREACHABLE();
}
void TransitionArray::SetKey(int transition_number, Name* key) {
......@@ -109,8 +94,7 @@ PropertyDetails TransitionsAccessor::GetTargetDetails(Name* name, Map* target) {
// static
Map* TransitionsAccessor::GetTargetFromRaw(Object* raw) {
if (raw->IsWeakCell()) return Map::cast(WeakCell::cast(raw)->value());
return Map::cast(StoreHandler::GetTransitionCell(raw)->value());
return Map::cast(WeakCell::cast(raw)->value());
}
Object* TransitionArray::GetRawTarget(int transition_number) {
......@@ -131,11 +115,6 @@ Map* TransitionsAccessor::GetTarget(int transition_number) {
return nullptr;
case kWeakRef:
return Map::cast(raw_transitions_->ToWeakHeapObject());
case kHandler: {
WeakCell* cell = GetTargetCell();
DCHECK(!cell->cleared());
return Map::cast(cell->value());
}
case kFullTransitionArray:
return transitions()->GetTarget(transition_number);
}
......
......@@ -20,9 +20,7 @@ void TransitionsAccessor::Initialize() {
} else if (raw_transitions_->IsWeakHeapObject()) {
encoding_ = kWeakRef;
} else if (raw_transitions_->ToStrongHeapObject(&heap_object)) {
if (heap_object->IsStoreHandler()) {
encoding_ = kHandler;
} else if (heap_object->IsTransitionArray()) {
if (heap_object->IsTransitionArray()) {
encoding_ = kFullTransitionArray;
} else {
DCHECK(heap_object->IsPrototypeInfo());
......@@ -31,7 +29,6 @@ void TransitionsAccessor::Initialize() {
} else {
UNREACHABLE();
}
target_cell_ = nullptr;
#if DEBUG
needs_reload_ = false;
#endif
......@@ -41,8 +38,6 @@ Map* TransitionsAccessor::GetSimpleTransition() {
switch (encoding()) {
case kWeakRef:
return Map::cast(raw_transitions_->ToWeakHeapObject());
case kHandler:
return Map::cast(GetTargetCell()->value());
default:
return nullptr;
}
......@@ -52,10 +47,6 @@ bool TransitionsAccessor::HasSimpleTransitionTo(Map* map) {
switch (encoding()) {
case kWeakRef:
return raw_transitions_->ToWeakHeapObject() == map;
case kHandler:
return StoreHandler::GetTransitionCell(
raw_transitions_->ToStrongHeapObject())
->value() == map;
case kPrototypeInfo:
case kUninitialized:
case kFullTransitionArray:
......@@ -108,9 +99,6 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
DCHECK_EQ(*map, simple_transition);
if (encoding_ == kWeakRef) {
result->Set(0, GetSimpleTransitionKey(simple_transition), *weak_cell);
} else if (encoding_ == kHandler) {
result->Set(0, GetSimpleTransitionKey(simple_transition),
raw_transitions_->ToStrongHeapObject());
} else {
UNREACHABLE();
}
......@@ -224,19 +212,14 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
Map* TransitionsAccessor::SearchTransition(Name* name, PropertyKind kind,
PropertyAttributes attributes) {
DCHECK(name->IsUniqueName());
Map* map = nullptr;
switch (encoding()) {
case kPrototypeInfo:
case kUninitialized:
return nullptr;
case kWeakRef:
map = Map::cast(raw_transitions_->ToWeakHeapObject());
break;
case kHandler: {
WeakCell* cell = GetTargetCell();
DCHECK(!cell->cleared());
map = Map::cast(cell->value());
break;
case kWeakRef: {
Map* map = Map::cast(raw_transitions_->ToWeakHeapObject());
if (!IsMatchingMap(map, name, kind, attributes)) return nullptr;
return map;
}
case kFullTransitionArray: {
int transition = transitions()->Search(kind, name, attributes);
......@@ -244,8 +227,7 @@ Map* TransitionsAccessor::SearchTransition(Name* name, PropertyKind kind,
return transitions()->GetTarget(transition);
}
}
if (!IsMatchingMap(map, name, kind, attributes)) return nullptr;
return map;
UNREACHABLE();
}
Map* TransitionsAccessor::SearchSpecial(Symbol* name) {
......@@ -283,29 +265,23 @@ MaybeHandle<Map> TransitionsAccessor::FindTransitionToDataProperty(
Handle<String> TransitionsAccessor::ExpectedTransitionKey() {
DisallowHeapAllocation no_gc;
Map* target = nullptr;
switch (encoding()) {
case kPrototypeInfo:
case kUninitialized:
case kFullTransitionArray:
return Handle<String>::null();
case kWeakRef:
target = Map::cast(raw_transitions_->ToWeakHeapObject());
break;
case kHandler: {
WeakCell* cell = GetTargetCell();
DCHECK(!cell->cleared());
target = Map::cast(cell->value());
break;
case kWeakRef: {
Map* target = Map::cast(raw_transitions_->ToWeakHeapObject());
PropertyDetails details = GetSimpleTargetDetails(target);
if (details.location() != kField) return Handle<String>::null();
DCHECK_EQ(kData, details.kind());
if (details.attributes() != NONE) return Handle<String>::null();
Name* name = GetSimpleTransitionKey(target);
if (!name->IsString()) return Handle<String>::null();
return handle(String::cast(name));
}
}
PropertyDetails details = GetSimpleTargetDetails(target);
if (details.location() != kField) return Handle<String>::null();
DCHECK_EQ(kData, details.kind());
if (details.attributes() != NONE) return Handle<String>::null();
Name* name = GetSimpleTransitionKey(target);
if (!name->IsString()) return Handle<String>::null();
return handle(String::cast(name));
UNREACHABLE();
}
Handle<Map> TransitionsAccessor::ExpectedTransitionTarget() {
......@@ -452,7 +428,6 @@ int TransitionsAccessor::NumberOfTransitions() {
case kUninitialized:
return 0;
case kWeakRef:
case kHandler:
return 1;
case kFullTransitionArray:
return transitions()->number_of_transitions();
......@@ -528,17 +503,16 @@ void TransitionsAccessor::EnsureHasFullTransitionArray() {
void TransitionsAccessor::TraverseTransitionTreeInternal(
TraverseCallback callback, void* data, DisallowHeapAllocation* no_gc) {
Map* simple_target = nullptr;
switch (encoding()) {
case kPrototypeInfo:
case kUninitialized:
break;
case kWeakRef:
simple_target = Map::cast(raw_transitions_->ToWeakHeapObject());
break;
case kHandler:
simple_target = Map::cast(GetTargetCell()->value());
case kWeakRef: {
Map* simple_target = Map::cast(raw_transitions_->ToWeakHeapObject());
TransitionsAccessor(simple_target, no_gc)
.TraverseTransitionTreeInternal(callback, data, no_gc);
break;
}
case kFullTransitionArray: {
if (transitions()->HasPrototypeTransitions()) {
FixedArray* proto_trans = transitions()->GetPrototypeTransitions();
......@@ -558,10 +532,6 @@ void TransitionsAccessor::TraverseTransitionTreeInternal(
break;
}
}
if (simple_target != nullptr) {
TransitionsAccessor(simple_target, no_gc)
.TraverseTransitionTreeInternal(callback, data, no_gc);
}
callback(map_, data);
}
......
......@@ -106,8 +106,7 @@ class TransitionsAccessor {
#if DEBUG || OBJECT_PRINT
void PrintTransitions(std::ostream& os);
static void PrintOneTransition(std::ostream& os, Name* key, Map* target,
Object* raw_target);
static void PrintOneTransition(std::ostream& os, Name* key, Map* target);
void PrintTransitionTree();
void PrintTransitionTree(std::ostream& os, int level,
DisallowHeapAllocation* no_gc);
......@@ -125,9 +124,6 @@ class TransitionsAccessor {
kPrototypeInfo,
kUninitialized,
kWeakRef,
// TODO(ishell): drop support for kHandler encoding since we use maps
// as transition handlers.
kHandler,
kFullTransitionArray,
};
......@@ -170,8 +166,6 @@ class TransitionsAccessor {
void ReplaceTransitions(MaybeObject* new_transitions);
inline WeakCell* GetTargetCell();
inline Map* GetTargetMapFromWeakRef();
void EnsureHasFullTransitionArray();
......@@ -187,7 +181,6 @@ class TransitionsAccessor {
Map* map_;
MaybeObject* raw_transitions_;
Encoding encoding_;
WeakCell* target_cell_;
#if DEBUG
bool needs_reload_;
#endif
......
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