Reland "Clean up DependentCode class."
This is a reland of 1ba5d5ba76
without any changes.
TBR=jarin@chromium.org
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}
Bug: v8:7902
Change-Id: I9ef70b88be1b31b458a95442ff3806d651e809ee
Reviewed-on: https://chromium-review.googlesource.com/1127719
Reviewed-by: Georg Neis <neis@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54289}
This commit is contained in:
parent
cf88badcfe
commit
ffd7ef24f7
@ -14953,32 +14953,17 @@ void JSArray::SetLength(Handle<JSArray> array, uint32_t new_length) {
|
|||||||
array->GetElementsAccessor()->SetLength(array, 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> DependentCode::InsertWeakCode(
|
||||||
Handle<DependentCode> entries, DependencyGroup group,
|
Handle<DependentCode> entries, DependencyGroup group,
|
||||||
Handle<WeakCell> code_cell) {
|
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) {
|
if (entries->length() == 0 || entries->group() > group) {
|
||||||
// There is no such group.
|
// There is no such group.
|
||||||
return DependentCode::New(group, object, entries);
|
return DependentCode::New(group, code_cell, entries);
|
||||||
}
|
}
|
||||||
if (entries->group() < group) {
|
if (entries->group() < group) {
|
||||||
// The group comes later in the list.
|
// The group comes later in the list.
|
||||||
Handle<DependentCode> old_next(entries->next_link(), entries->GetIsolate());
|
Handle<DependentCode> old_next(entries->next_link(), entries->GetIsolate());
|
||||||
Handle<DependentCode> new_next = Insert(old_next, group, object);
|
Handle<DependentCode> new_next = InsertWeakCode(old_next, group, code_cell);
|
||||||
if (!old_next.is_identical_to(new_next)) {
|
if (!old_next.is_identical_to(new_next)) {
|
||||||
entries->set_next_link(*new_next);
|
entries->set_next_link(*new_next);
|
||||||
}
|
}
|
||||||
@ -14988,14 +14973,14 @@ Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries,
|
|||||||
int count = entries->count();
|
int count = entries->count();
|
||||||
// Check for existing entry to avoid duplicates.
|
// Check for existing entry to avoid duplicates.
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if (entries->object_at(i) == *object) return entries;
|
if (entries->object_at(i) == *code_cell) return entries;
|
||||||
}
|
}
|
||||||
if (entries->length() < kCodesStartIndex + count + 1) {
|
if (entries->length() < kCodesStartIndex + count + 1) {
|
||||||
entries = EnsureSpace(entries);
|
entries = EnsureSpace(entries);
|
||||||
// Count could have changed, reload it.
|
// Count could have changed, reload it.
|
||||||
count = entries->count();
|
count = entries->count();
|
||||||
}
|
}
|
||||||
entries->set_object_at(count, *object);
|
entries->set_object_at(count, *code_cell);
|
||||||
entries->set_count(count + 1);
|
entries->set_count(count + 1);
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
@ -155,10 +155,6 @@ DependentCode::DependencyGroup DependentCode::group() {
|
|||||||
return static_cast<DependencyGroup>(GroupField::decode(flags()));
|
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) {
|
void DependentCode::set_object_at(int i, Object* object) {
|
||||||
set(kCodesStartIndex + i, object);
|
set(kCodesStartIndex + i, object);
|
||||||
}
|
}
|
||||||
|
@ -589,6 +589,8 @@ class AbstractCode : public HeapObject {
|
|||||||
|
|
||||||
class DependentCode : public FixedArray {
|
class DependentCode : public FixedArray {
|
||||||
public:
|
public:
|
||||||
|
DECL_CAST(DependentCode)
|
||||||
|
|
||||||
enum DependencyGroup {
|
enum DependencyGroup {
|
||||||
// Group of code that embed a transition to this map, and depend on being
|
// Group of code that embed a transition to this map, and depend on being
|
||||||
// deoptimized when the transition is replaced by a new version.
|
// deoptimized when the transition is replaced by a new version.
|
||||||
@ -615,18 +617,9 @@ class DependentCode : public FixedArray {
|
|||||||
kAllocationSiteTransitionChangedGroup
|
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 Contains(DependencyGroup group, WeakCell* code_cell);
|
||||||
bool IsEmpty(DependencyGroup group);
|
bool IsEmpty(DependencyGroup group);
|
||||||
|
|
||||||
static Handle<DependentCode> InsertCompilationDependencies(
|
|
||||||
Handle<DependentCode> entries, DependencyGroup group,
|
|
||||||
Handle<Foreign> info);
|
|
||||||
|
|
||||||
static Handle<DependentCode> InsertWeakCode(Handle<DependentCode> entries,
|
static Handle<DependentCode> InsertWeakCode(Handle<DependentCode> entries,
|
||||||
DependencyGroup group,
|
DependencyGroup group,
|
||||||
Handle<WeakCell> code_cell);
|
Handle<WeakCell> code_cell);
|
||||||
@ -640,36 +633,39 @@ class DependentCode : public FixedArray {
|
|||||||
bool MarkCodeForDeoptimization(Isolate* isolate,
|
bool MarkCodeForDeoptimization(Isolate* isolate,
|
||||||
DependentCode::DependencyGroup group);
|
DependentCode::DependencyGroup group);
|
||||||
|
|
||||||
// The following low-level accessors should only be used by this class
|
// The following low-level accessors are exposed only for tests.
|
||||||
// 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 DependencyGroup group();
|
||||||
inline void set_group(DependencyGroup group);
|
|
||||||
inline Object* object_at(int i);
|
inline Object* object_at(int i);
|
||||||
inline void set_object_at(int i, Object* object);
|
inline int count();
|
||||||
inline void clear_at(int i);
|
inline DependentCode* next_link();
|
||||||
inline void copy(int from, int to);
|
|
||||||
DECL_CAST(DependentCode)
|
|
||||||
|
|
||||||
static const char* DependencyGroupName(DependencyGroup group);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Handle<DependentCode> Insert(Handle<DependentCode> entries,
|
static const char* DependencyGroupName(DependencyGroup group);
|
||||||
DependencyGroup group,
|
|
||||||
Handle<Object> object);
|
|
||||||
static Handle<DependentCode> New(DependencyGroup group, Handle<Object> object,
|
static Handle<DependentCode> New(DependencyGroup group, Handle<Object> object,
|
||||||
Handle<DependentCode> next);
|
Handle<DependentCode> next);
|
||||||
static Handle<DependentCode> EnsureSpace(Handle<DependentCode> entries);
|
static Handle<DependentCode> EnsureSpace(Handle<DependentCode> entries);
|
||||||
|
|
||||||
// Compact by removing cleared weak cells and return true if there was
|
// Compact by removing cleared weak cells and return true if there was
|
||||||
// any cleared weak cell.
|
// any cleared weak cell.
|
||||||
bool Compact();
|
bool Compact();
|
||||||
|
|
||||||
static int Grow(int number_of_entries) {
|
static int Grow(int number_of_entries) {
|
||||||
if (number_of_entries < 5) return number_of_entries + 1;
|
if (number_of_entries < 5) return number_of_entries + 1;
|
||||||
return number_of_entries * 5 / 4;
|
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 int flags();
|
||||||
inline void set_flags(int flags);
|
inline void set_flags(int flags);
|
||||||
class GroupField : public BitField<int, 0, 3> {};
|
class GroupField : public BitField<int, 0, 3> {};
|
||||||
|
Loading…
Reference in New Issue
Block a user