Commit f3054adc authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

Revert "Clean up DependentCode class."

This reverts commit 1ba5d5ba.

Reason for revert: Follow-up revert for b1cf1e1e

Original change's description:
> Clean up DependentCode class.
> 
> Also move some helpers there.
> 
> Bug: v8:7902
> Change-Id: I1ef3d1e8317102afae2861382e9ba60b0ef6bba4
> Reviewed-on: https://chromium-review.googlesource.com/1121461
> Commit-Queue: Georg Neis <neis@chromium.org>
> Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#54179}

TBR=jarin@chromium.org,neis@chromium.org

Change-Id: I02f01f9e8f3bcea13339d4eb87eab784b16f4ad1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:7902
Reviewed-on: https://chromium-review.googlesource.com/1125681Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54194}
parent 512175a3
......@@ -14941,17 +14941,32 @@ void JSArray::SetLength(Handle<JSArray> array, uint32_t new_length) {
array->GetElementsAccessor()->SetLength(array, new_length);
}
Handle<DependentCode> DependentCode::InsertCompilationDependencies(
Handle<DependentCode> entries, DependencyGroup group,
Handle<Foreign> info) {
return Insert(entries, group, info);
}
Handle<DependentCode> DependentCode::InsertWeakCode(
Handle<DependentCode> entries, DependencyGroup group,
Handle<WeakCell> code_cell) {
return Insert(entries, group, code_cell);
}
Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries,
DependencyGroup group,
Handle<Object> object) {
if (entries->length() == 0 || entries->group() > group) {
// There is no such group.
return DependentCode::New(group, code_cell, entries);
return DependentCode::New(group, object, entries);
}
if (entries->group() < group) {
// The group comes later in the list.
Handle<DependentCode> old_next(entries->next_link(), entries->GetIsolate());
Handle<DependentCode> new_next = InsertWeakCode(old_next, group, code_cell);
Handle<DependentCode> new_next = Insert(old_next, group, object);
if (!old_next.is_identical_to(new_next)) {
entries->set_next_link(*new_next);
}
......@@ -14961,14 +14976,14 @@ Handle<DependentCode> DependentCode::InsertWeakCode(
int count = entries->count();
// Check for existing entry to avoid duplicates.
for (int i = 0; i < count; i++) {
if (entries->object_at(i) == *code_cell) return entries;
if (entries->object_at(i) == *object) return entries;
}
if (entries->length() < kCodesStartIndex + count + 1) {
entries = EnsureSpace(entries);
// Count could have changed, reload it.
count = entries->count();
}
entries->set_object_at(count, *code_cell);
entries->set_object_at(count, *object);
entries->set_count(count + 1);
return entries;
}
......
......@@ -155,6 +155,10 @@ DependentCode::DependencyGroup DependentCode::group() {
return static_cast<DependencyGroup>(GroupField::decode(flags()));
}
void DependentCode::set_group(DependentCode::DependencyGroup group) {
set_flags(GroupField::update(flags(), static_cast<int>(group)));
}
void DependentCode::set_object_at(int i, Object* object) {
set(kCodesStartIndex + i, object);
}
......
......@@ -589,8 +589,6 @@ class AbstractCode : public HeapObject {
class DependentCode : public FixedArray {
public:
DECL_CAST(DependentCode)
enum DependencyGroup {
// Group of code that embed a transition to this map, and depend on being
// deoptimized when the transition is replaced by a new version.
......@@ -617,9 +615,18 @@ class DependentCode : public FixedArray {
kAllocationSiteTransitionChangedGroup
};
static const int kGroupCount = kAllocationSiteTransitionChangedGroup + 1;
static const int kNextLinkIndex = 0;
static const int kFlagsIndex = 1;
static const int kCodesStartIndex = 2;
bool Contains(DependencyGroup group, WeakCell* code_cell);
bool IsEmpty(DependencyGroup group);
static Handle<DependentCode> InsertCompilationDependencies(
Handle<DependentCode> entries, DependencyGroup group,
Handle<Foreign> info);
static Handle<DependentCode> InsertWeakCode(Handle<DependentCode> entries,
DependencyGroup group,
Handle<WeakCell> code_cell);
......@@ -636,39 +643,36 @@ class DependentCode : public FixedArray {
bool MarkCodeForDeoptimization(Isolate* isolate,
DependentCode::DependencyGroup group);
// The following low-level accessors are exposed only for tests.
// The following low-level accessors should only be used by this class
// and the mark compact collector.
inline DependentCode* next_link();
inline void set_next_link(DependentCode* next);
inline int count();
inline void set_count(int value);
inline DependencyGroup group();
inline void set_group(DependencyGroup group);
inline Object* object_at(int i);
inline int count();
inline DependentCode* next_link();
inline void set_object_at(int i, Object* object);
inline void clear_at(int i);
inline void copy(int from, int to);
DECL_CAST(DependentCode)
private:
static const char* DependencyGroupName(DependencyGroup group);
private:
static Handle<DependentCode> Insert(Handle<DependentCode> entries,
DependencyGroup group,
Handle<Object> object);
static Handle<DependentCode> New(DependencyGroup group, Handle<Object> object,
Handle<DependentCode> next);
static Handle<DependentCode> EnsureSpace(Handle<DependentCode> entries);
// Compact by removing cleared weak cells and return true if there was
// any cleared weak cell.
bool Compact();
static int Grow(int number_of_entries) {
if (number_of_entries < 5) return number_of_entries + 1;
return number_of_entries * 5 / 4;
}
static const int kGroupCount = kAllocationSiteTransitionChangedGroup + 1;
static const int kNextLinkIndex = 0;
static const int kFlagsIndex = 1;
static const int kCodesStartIndex = 2;
inline void set_next_link(DependentCode* next);
inline void set_count(int value);
inline void set_object_at(int i, Object* object);
inline void clear_at(int i);
inline void copy(int from, int to);
inline int flags();
inline void set_flags(int flags);
class GroupField : public BitField<int, 0, 3> {};
......
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