Commit 7bba17bc authored by ulan's avatar ulan Committed by Commit bot

Revert of Replace ad-hoc weakness in transition array with WeakCell. (patchset...

Revert of Replace ad-hoc weakness in transition array with WeakCell. (patchset #5 id:80001 of https://codereview.chromium.org/1157943003/)

Reason for revert:
Breaks descriptor array clearing.

Original issue's description:
> Replace ad-hoc weakness in transition array with WeakCell.
>
> BUG=
>
> Committed: https://crrev.com/885455e99de817f86a0b5df2dc0d932cfc179749
> Cr-Commit-Position: refs/heads/master@{#29083}

TBR=jkummerow@chromium.org,hpayer@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=

Review URL: https://codereview.chromium.org/1194673002

Cr-Commit-Position: refs/heads/master@{#29121}
parent 19cdd00d
...@@ -2468,39 +2468,25 @@ void MarkCompactCollector::ClearMapTransitions(Map* map, Map* dead_transition) { ...@@ -2468,39 +2468,25 @@ void MarkCompactCollector::ClearMapTransitions(Map* map, Map* dead_transition) {
int transition_index = 0; int transition_index = 0;
// This flag will be cleared if we find the live owner in the loop below. bool descriptors_owner_died = false;
bool descriptors_owner_died = true;
// Compact all live descriptors to the left. // Compact all live descriptors to the left.
if (TransitionArray::IsFullTransitionArray(transitions)) { for (int i = 0; i < num_transitions; ++i) {
for (int i = 0; i < num_transitions; ++i) { Map* target = TransitionArray::GetTarget(transitions, i);
WeakCell* target_cell = if (ClearMapBackPointer(target)) {
TransitionArray::cast(transitions)->GetTargetCell(i); if (target->instance_descriptors() == descriptors) {
if (!target_cell->cleared()) { descriptors_owner_died = true;
if (Map::cast(target_cell->value())->instance_descriptors() ==
descriptors) {
descriptors_owner_died = false;
}
if (i != transition_index) {
TransitionArray* t = TransitionArray::cast(transitions);
Name* key = t->GetKey(i);
t->SetKey(transition_index, key);
Object** key_slot = t->GetKeySlot(transition_index);
RecordSlot(key_slot, key_slot, key);
WeakCell* target_cell = t->GetTargetCell(i);
t->SetTargetCell(transition_index, target_cell);
Object** target_slot = t->GetTargetSlot(transition_index);
RecordSlot(target_slot, target_slot, target_cell);
}
transition_index++;
} }
} } else {
} else if (transitions->IsWeakCell()) { if (i != transition_index) {
WeakCell* target_cell = WeakCell::cast(transitions); DCHECK(TransitionArray::IsFullTransitionArray(transitions));
if (!target_cell->cleared()) { TransitionArray* t = TransitionArray::cast(transitions);
if (Map::cast(target_cell->value())->instance_descriptors() == Name* key = t->GetKey(i);
descriptors) { t->SetKey(transition_index, key);
descriptors_owner_died = false; Object** key_slot = t->GetKeySlot(transition_index);
RecordSlot(key_slot, key_slot, key);
// Target slots do not need to be recorded since maps are not compacted.
t->SetTarget(transition_index, t->GetTarget(i));
} }
transition_index++; transition_index++;
} }
......
...@@ -537,6 +537,11 @@ void StaticMarkingVisitor<StaticVisitor>::VisitJSDataView(Map* map, ...@@ -537,6 +537,11 @@ void StaticMarkingVisitor<StaticVisitor>::VisitJSDataView(Map* map,
template <typename StaticVisitor> template <typename StaticVisitor>
void StaticMarkingVisitor<StaticVisitor>::MarkMapContents(Heap* heap, void StaticMarkingVisitor<StaticVisitor>::MarkMapContents(Heap* heap,
Map* map) { Map* map) {
Object* raw_transitions = map->raw_transitions();
if (TransitionArray::IsFullTransitionArray(raw_transitions)) {
MarkTransitionArray(heap, TransitionArray::cast(raw_transitions));
}
// Since descriptor arrays are potentially shared, ensure that only the // Since descriptor arrays are potentially shared, ensure that only the
// descriptors that belong to this map are marked. The first time a // descriptors that belong to this map are marked. The first time a
// non-empty descriptor array is marked, its header is also visited. The slot // non-empty descriptor array is marked, its header is also visited. The slot
...@@ -565,6 +570,23 @@ void StaticMarkingVisitor<StaticVisitor>::MarkMapContents(Heap* heap, ...@@ -565,6 +570,23 @@ void StaticMarkingVisitor<StaticVisitor>::MarkMapContents(Heap* heap,
} }
template <typename StaticVisitor>
void StaticMarkingVisitor<StaticVisitor>::MarkTransitionArray(
Heap* heap, TransitionArray* transitions) {
if (!StaticVisitor::MarkObjectWithoutPush(heap, transitions)) return;
if (transitions->HasPrototypeTransitions()) {
StaticVisitor::VisitPointer(heap,
transitions->GetPrototypeTransitionsSlot());
}
int num_transitions = TransitionArray::NumberOfTransitions(transitions);
for (int i = 0; i < num_transitions; ++i) {
StaticVisitor::VisitPointer(heap, transitions->GetKeySlot(i));
}
}
template <typename StaticVisitor> template <typename StaticVisitor>
void StaticMarkingVisitor<StaticVisitor>::MarkInlinedFunctionsCode(Heap* heap, void StaticMarkingVisitor<StaticVisitor>::MarkInlinedFunctionsCode(Heap* heap,
Code* code) { Code* code) {
......
...@@ -438,6 +438,7 @@ class StaticMarkingVisitor : public StaticVisitorBase { ...@@ -438,6 +438,7 @@ class StaticMarkingVisitor : public StaticVisitorBase {
// Mark pointers in a Map and its TransitionArray together, possibly // Mark pointers in a Map and its TransitionArray together, possibly
// treating transitions or back pointers weak. // treating transitions or back pointers weak.
static void MarkMapContents(Heap* heap, Map* map); static void MarkMapContents(Heap* heap, Map* map);
static void MarkTransitionArray(Heap* heap, TransitionArray* transitions);
// Code flushing support. // Code flushing support.
INLINE(static bool IsFlushable(Heap* heap, JSFunction* function)); INLINE(static bool IsFlushable(Heap* heap, JSFunction* function));
......
...@@ -47,12 +47,6 @@ Object** TransitionArray::GetKeySlot(int transition_number) { ...@@ -47,12 +47,6 @@ Object** TransitionArray::GetKeySlot(int transition_number) {
} }
Object** TransitionArray::GetTargetSlot(int transition_number) {
DCHECK(transition_number < number_of_transitions());
return RawFieldOfElementAt(ToTargetIndex(transition_number));
}
Name* TransitionArray::GetKey(int transition_number) { Name* TransitionArray::GetKey(int transition_number) {
DCHECK(transition_number < number_of_transitions()); DCHECK(transition_number < number_of_transitions());
return Name::cast(get(ToKeyIndex(transition_number))); return Name::cast(get(ToKeyIndex(transition_number)));
...@@ -77,8 +71,7 @@ void TransitionArray::SetKey(int transition_number, Name* key) { ...@@ -77,8 +71,7 @@ void TransitionArray::SetKey(int transition_number, Name* key) {
Map* TransitionArray::GetTarget(int transition_number) { Map* TransitionArray::GetTarget(int transition_number) {
DCHECK(transition_number < number_of_transitions()); DCHECK(transition_number < number_of_transitions());
WeakCell* cell = GetTargetCell(transition_number); return Map::cast(get(ToTargetIndex(transition_number)));
return Map::cast(cell->value());
} }
...@@ -93,13 +86,7 @@ Map* TransitionArray::GetTarget(Object* raw_transitions, ...@@ -93,13 +86,7 @@ Map* TransitionArray::GetTarget(Object* raw_transitions,
} }
WeakCell* TransitionArray::GetTargetCell(int transition_number) { void TransitionArray::SetTarget(int transition_number, Map* value) {
DCHECK(transition_number < number_of_transitions());
return WeakCell::cast(get(ToTargetIndex(transition_number)));
}
void TransitionArray::SetTargetCell(int transition_number, WeakCell* value) {
DCHECK(transition_number < number_of_transitions()); DCHECK(transition_number < number_of_transitions());
set(ToTargetIndex(transition_number), value); set(ToTargetIndex(transition_number), value);
} }
...@@ -171,9 +158,13 @@ PropertyDetails TransitionArray::GetTargetDetails(Name* name, Map* target) { ...@@ -171,9 +158,13 @@ PropertyDetails TransitionArray::GetTargetDetails(Name* name, Map* target) {
} }
void TransitionArray::Set(int transition_number, Name* key, WeakCell* target) { void TransitionArray::NoIncrementalWriteBarrierSet(int transition_number,
set(ToKeyIndex(transition_number), key); Name* key,
set(ToTargetIndex(transition_number), target); Map* target) {
FixedArray::NoIncrementalWriteBarrierSet(
this, ToKeyIndex(transition_number), key);
FixedArray::NoIncrementalWriteBarrierSet(
this, ToTargetIndex(transition_number), target);
} }
......
...@@ -17,11 +17,11 @@ void TransitionArray::Insert(Handle<Map> map, Handle<Name> name, ...@@ -17,11 +17,11 @@ void TransitionArray::Insert(Handle<Map> map, Handle<Name> name,
Handle<Map> target, SimpleTransitionFlag flag) { Handle<Map> target, SimpleTransitionFlag flag) {
Isolate* isolate = map->GetIsolate(); Isolate* isolate = map->GetIsolate();
target->SetBackPointer(*map); target->SetBackPointer(*map);
Handle<WeakCell> cell = Map::WeakCellForMap(target);
// If the map doesn't have any transitions at all yet, install the new one. // If the map doesn't have any transitions at all yet, install the new one.
if (CanStoreSimpleTransition(map->raw_transitions())) { if (CanStoreSimpleTransition(map->raw_transitions())) {
if (flag == SIMPLE_PROPERTY_TRANSITION) { if (flag == SIMPLE_PROPERTY_TRANSITION) {
Handle<WeakCell> cell = Map::WeakCellForMap(target);
ReplaceTransitions(map, *cell); ReplaceTransitions(map, *cell);
return; return;
} }
...@@ -42,6 +42,7 @@ void TransitionArray::Insert(Handle<Map> map, Handle<Name> name, ...@@ -42,6 +42,7 @@ void TransitionArray::Insert(Handle<Map> map, Handle<Name> name,
if (flag == SIMPLE_PROPERTY_TRANSITION && key->Equals(*name) && if (flag == SIMPLE_PROPERTY_TRANSITION && key->Equals(*name) &&
old_details.kind() == new_details.kind() && old_details.kind() == new_details.kind() &&
old_details.attributes() == new_details.attributes()) { old_details.attributes() == new_details.attributes()) {
Handle<WeakCell> cell = Map::WeakCellForMap(target);
ReplaceTransitions(map, *cell); ReplaceTransitions(map, *cell);
return; return;
} }
...@@ -50,8 +51,8 @@ void TransitionArray::Insert(Handle<Map> map, Handle<Name> name, ...@@ -50,8 +51,8 @@ void TransitionArray::Insert(Handle<Map> map, Handle<Name> name,
// Re-read existing data; the allocation might have caused it to be cleared. // Re-read existing data; the allocation might have caused it to be cleared.
if (IsSimpleTransition(map->raw_transitions())) { if (IsSimpleTransition(map->raw_transitions())) {
old_target = GetSimpleTransition(map->raw_transitions()); old_target = GetSimpleTransition(map->raw_transitions());
result->Set(0, GetSimpleTransitionKey(old_target), result->NoIncrementalWriteBarrierSet(
GetSimpleTransitionCell(map->raw_transitions())); 0, GetSimpleTransitionKey(old_target), old_target);
} else { } else {
result->SetNumberOfTransitions(0); result->SetNumberOfTransitions(0);
} }
...@@ -82,7 +83,7 @@ void TransitionArray::Insert(Handle<Map> map, Handle<Name> name, ...@@ -82,7 +83,7 @@ void TransitionArray::Insert(Handle<Map> map, Handle<Name> name,
&insertion_index); &insertion_index);
// If an existing entry was found, overwrite it and return. // If an existing entry was found, overwrite it and return.
if (index != kNotFound) { if (index != kNotFound) {
array->SetTargetCell(index, *cell); array->SetTarget(index, *target);
return; return;
} }
...@@ -95,10 +96,10 @@ void TransitionArray::Insert(Handle<Map> map, Handle<Name> name, ...@@ -95,10 +96,10 @@ void TransitionArray::Insert(Handle<Map> map, Handle<Name> name,
array->SetNumberOfTransitions(new_nof); array->SetNumberOfTransitions(new_nof);
for (index = number_of_transitions; index > insertion_index; --index) { for (index = number_of_transitions; index > insertion_index; --index) {
array->SetKey(index, array->GetKey(index - 1)); array->SetKey(index, array->GetKey(index - 1));
array->SetTargetCell(index, array->GetTargetCell(index - 1)); array->SetTarget(index, array->GetTarget(index - 1));
} }
array->SetKey(index, *name); array->SetKey(index, *name);
array->SetTargetCell(index, *cell); array->SetTarget(index, *target);
SLOW_DCHECK(array->IsSortedNoDuplicates()); SLOW_DCHECK(array->IsSortedNoDuplicates());
return; return;
} }
...@@ -144,11 +145,11 @@ void TransitionArray::Insert(Handle<Map> map, Handle<Name> name, ...@@ -144,11 +145,11 @@ void TransitionArray::Insert(Handle<Map> map, Handle<Name> name,
DCHECK_NE(kNotFound, insertion_index); DCHECK_NE(kNotFound, insertion_index);
for (int i = 0; i < insertion_index; ++i) { for (int i = 0; i < insertion_index; ++i) {
result->CopyFrom(array, i, i); result->NoIncrementalWriteBarrierCopyFrom(array, i, i);
} }
result->Set(insertion_index, *name, *cell); result->NoIncrementalWriteBarrierSet(insertion_index, *name, *target);
for (int i = insertion_index; i < number_of_transitions; ++i) { for (int i = insertion_index; i < number_of_transitions; ++i) {
result->CopyFrom(array, i, i + 1); result->NoIncrementalWriteBarrierCopyFrom(array, i, i + 1);
} }
SLOW_DCHECK(result->IsSortedNoDuplicates()); SLOW_DCHECK(result->IsSortedNoDuplicates());
...@@ -348,10 +349,12 @@ Handle<TransitionArray> TransitionArray::Allocate(Isolate* isolate, ...@@ -348,10 +349,12 @@ Handle<TransitionArray> TransitionArray::Allocate(Isolate* isolate,
} }
void TransitionArray::CopyFrom(TransitionArray* origin, int origin_transition, void TransitionArray::NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin,
int target_transition) { int origin_transition,
Set(target_transition, origin->GetKey(origin_transition), int target_transition) {
origin->GetTargetCell(origin_transition)); NoIncrementalWriteBarrierSet(target_transition,
origin->GetKey(origin_transition),
origin->GetTarget(origin_transition));
} }
...@@ -419,9 +422,9 @@ void TransitionArray::EnsureHasFullTransitionArray(Handle<Map> map) { ...@@ -419,9 +422,9 @@ void TransitionArray::EnsureHasFullTransitionArray(Handle<Map> map) {
result->Shrink(ToKeyIndex(0)); result->Shrink(ToKeyIndex(0));
result->SetNumberOfTransitions(0); result->SetNumberOfTransitions(0);
} else if (nof == 1) { } else if (nof == 1) {
WeakCell* target_cell = GetSimpleTransitionCell(raw_transitions); Map* target = GetSimpleTransition(raw_transitions);
Name* key = GetSimpleTransitionKey(Map::cast(target_cell->value())); Name* key = GetSimpleTransitionKey(target);
result->Set(0, key, target_cell); result->NoIncrementalWriteBarrierSet(0, key, target);
} }
ReplaceTransitions(map, *result); ReplaceTransitions(map, *result);
} }
......
...@@ -71,11 +71,6 @@ class TransitionArray: public FixedArray { ...@@ -71,11 +71,6 @@ class TransitionArray: public FixedArray {
DCHECK(raw_transition->IsWeakCell()); DCHECK(raw_transition->IsWeakCell());
return Map::cast(WeakCell::cast(raw_transition)->value()); return Map::cast(WeakCell::cast(raw_transition)->value());
} }
static inline WeakCell* GetSimpleTransitionCell(Object* raw_transition) {
DCHECK(IsSimpleTransition(raw_transition));
DCHECK(raw_transition->IsWeakCell());
return WeakCell::cast(raw_transition);
}
static inline bool IsFullTransitionArray(Object* raw_transitions) { static inline bool IsFullTransitionArray(Object* raw_transitions) {
return raw_transitions->IsTransitionArray(); return raw_transitions->IsTransitionArray();
} }
...@@ -140,7 +135,6 @@ class TransitionArray: public FixedArray { ...@@ -140,7 +135,6 @@ class TransitionArray: public FixedArray {
inline Name* GetKey(int transition_number); inline Name* GetKey(int transition_number);
inline void SetKey(int transition_number, Name* value); inline void SetKey(int transition_number, Name* value);
inline Object** GetKeySlot(int transition_number); inline Object** GetKeySlot(int transition_number);
inline Object** GetTargetSlot(int transition_number);
int GetSortedKeyIndex(int transition_number) { return transition_number; } int GetSortedKeyIndex(int transition_number) { return transition_number; }
Name* GetSortedKey(int transition_number) { Name* GetSortedKey(int transition_number) {
...@@ -149,9 +143,7 @@ class TransitionArray: public FixedArray { ...@@ -149,9 +143,7 @@ class TransitionArray: public FixedArray {
static inline Map* GetTarget(Object* raw_transitions, int transition_number); static inline Map* GetTarget(Object* raw_transitions, int transition_number);
inline Map* GetTarget(int transition_number); inline Map* GetTarget(int transition_number);
inline void SetTarget(int transition_number, Map* target);
inline WeakCell* GetTargetCell(int transition_number);
inline void SetTargetCell(int transition_number, WeakCell* target);
static inline PropertyDetails GetTargetDetails(Name* name, Map* target); static inline PropertyDetails GetTargetDetails(Name* name, Map* target);
...@@ -291,11 +283,14 @@ class TransitionArray: public FixedArray { ...@@ -291,11 +283,14 @@ class TransitionArray: public FixedArray {
PropertyKind kind2, PropertyKind kind2,
PropertyAttributes attributes2); PropertyAttributes attributes2);
inline void Set(int transition_number, Name* key, WeakCell* target_cell); inline void NoIncrementalWriteBarrierSet(int transition_number,
Name* key,
Map* target);
// Copy a single transition from the origin array. // Copy a single transition from the origin array.
inline void CopyFrom(TransitionArray* origin, int origin_transition, inline void NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin,
int target_transition); int origin_transition,
int target_transition);
#ifdef DEBUG #ifdef DEBUG
static void CheckNewTransitionsAreConsistent(Handle<Map> map, static void CheckNewTransitionsAreConsistent(Handle<Map> map,
......
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