Commit fa067fb9 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

Move some helpers to the DependentCode class, where they belong.

R=jarin@chromium.org

Bug: v8:7902
Change-Id: I402b2711b8a5a820b8c95285dc929f2a10c55f98
Reviewed-on: https://chromium-review.googlesource.com/1127883
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54298}
parent 08a4fe71
......@@ -11,42 +11,6 @@ namespace v8 {
namespace internal {
namespace compiler {
// TODO(neis): Move these to the DependentCode class.
namespace {
DependentCode* GetDependentCode(Handle<Object> object) {
if (object->IsMap()) {
return Handle<Map>::cast(object)->dependent_code();
} else if (object->IsPropertyCell()) {
return Handle<PropertyCell>::cast(object)->dependent_code();
} else if (object->IsAllocationSite()) {
return Handle<AllocationSite>::cast(object)->dependent_code();
}
UNREACHABLE();
}
void SetDependentCode(Handle<Object> object, Handle<DependentCode> dep) {
if (object->IsMap()) {
Handle<Map>::cast(object)->set_dependent_code(*dep);
} else if (object->IsPropertyCell()) {
Handle<PropertyCell>::cast(object)->set_dependent_code(*dep);
} else if (object->IsAllocationSite()) {
Handle<AllocationSite>::cast(object)->set_dependent_code(*dep);
} else {
UNREACHABLE();
}
}
void InstallDependency(Isolate* isolate, Handle<WeakCell> source,
Handle<HeapObject> target,
DependentCode::DependencyGroup group) {
Handle<DependentCode> old_deps(GetDependentCode(target), isolate);
Handle<DependentCode> new_deps =
DependentCode::InsertWeakCode(old_deps, group, source);
// Update the list head if necessary.
if (!new_deps.is_identical_to(old_deps)) SetDependentCode(target, new_deps);
}
} // namespace
CompilationDependencies::CompilationDependencies(Isolate* isolate, Zone* zone)
: isolate_(isolate), zone_(zone), dependencies_(zone) {}
......@@ -71,8 +35,8 @@ class InitialMapDependency final : public CompilationDependencies::Dependency {
void Install(Isolate* isolate, Handle<WeakCell> code) override {
DCHECK(IsValid());
InstallDependency(isolate, code, initial_map_,
DependentCode::kInitialMapChangedGroup);
DependentCode::InstallDependency(isolate, code, initial_map_,
DependentCode::kInitialMapChangedGroup);
}
private:
......@@ -93,7 +57,8 @@ class StableMapDependency final : public CompilationDependencies::Dependency {
void Install(Isolate* isolate, Handle<WeakCell> code) override {
DCHECK(IsValid());
InstallDependency(isolate, code, map_, DependentCode::kPrototypeCheckGroup);
DependentCode::InstallDependency(isolate, code, map_,
DependentCode::kPrototypeCheckGroup);
}
private:
......@@ -113,7 +78,8 @@ class TransitionDependency final : public CompilationDependencies::Dependency {
void Install(Isolate* isolate, Handle<WeakCell> code) override {
DCHECK(IsValid());
InstallDependency(isolate, code, map_, DependentCode::kTransitionGroup);
DependentCode::InstallDependency(isolate, code, map_,
DependentCode::kTransitionGroup);
}
private:
......@@ -135,8 +101,9 @@ class PretenureModeDependency final
void Install(Isolate* isolate, Handle<WeakCell> code) override {
DCHECK(IsValid());
InstallDependency(isolate, code, site_,
DependentCode::kAllocationSiteTenuringChangedGroup);
DependentCode::InstallDependency(
isolate, code, site_,
DependentCode::kAllocationSiteTenuringChangedGroup);
}
private:
......@@ -160,7 +127,8 @@ class FieldTypeDependency final : public CompilationDependencies::Dependency {
void Install(Isolate* isolate, Handle<WeakCell> code) override {
DCHECK(IsValid());
InstallDependency(isolate, code, owner_, DependentCode::kFieldOwnerGroup);
DependentCode::InstallDependency(isolate, code, owner_,
DependentCode::kFieldOwnerGroup);
}
private:
......@@ -187,8 +155,8 @@ class GlobalPropertyDependency final
void Install(Isolate* isolate, Handle<WeakCell> code) override {
DCHECK(IsValid());
InstallDependency(isolate, code, cell_,
DependentCode::kPropertyCellChangedGroup);
DependentCode::InstallDependency(isolate, code, cell_,
DependentCode::kPropertyCellChangedGroup);
}
private:
......@@ -210,8 +178,8 @@ class ProtectorDependency final : public CompilationDependencies::Dependency {
void Install(Isolate* isolate, Handle<WeakCell> code) override {
DCHECK(IsValid());
InstallDependency(isolate, code, cell_,
DependentCode::kPropertyCellChangedGroup);
DependentCode::InstallDependency(isolate, code, cell_,
DependentCode::kPropertyCellChangedGroup);
}
private:
......@@ -237,8 +205,9 @@ class ElementsKindDependency final
void Install(Isolate* isolate, Handle<WeakCell> code) override {
DCHECK(IsValid());
InstallDependency(isolate, code, site_,
DependentCode::kAllocationSiteTransitionChangedGroup);
DependentCode::InstallDependency(
isolate, code, site_,
DependentCode::kAllocationSiteTransitionChangedGroup);
}
private:
......
......@@ -14953,6 +14953,38 @@ void JSArray::SetLength(Handle<JSArray> array, uint32_t new_length) {
array->GetElementsAccessor()->SetLength(array, new_length);
}
DependentCode* DependentCode::Get(Handle<HeapObject> object) {
if (object->IsMap()) {
return Handle<Map>::cast(object)->dependent_code();
} else if (object->IsPropertyCell()) {
return Handle<PropertyCell>::cast(object)->dependent_code();
} else if (object->IsAllocationSite()) {
return Handle<AllocationSite>::cast(object)->dependent_code();
}
UNREACHABLE();
}
void DependentCode::Set(Handle<HeapObject> object, Handle<DependentCode> dep) {
if (object->IsMap()) {
Handle<Map>::cast(object)->set_dependent_code(*dep);
} else if (object->IsPropertyCell()) {
Handle<PropertyCell>::cast(object)->set_dependent_code(*dep);
} else if (object->IsAllocationSite()) {
Handle<AllocationSite>::cast(object)->set_dependent_code(*dep);
} else {
UNREACHABLE();
}
}
void DependentCode::InstallDependency(Isolate* isolate, Handle<WeakCell> cell,
Handle<HeapObject> object,
DependencyGroup group) {
Handle<DependentCode> old_deps(DependentCode::Get(object), isolate);
Handle<DependentCode> new_deps = InsertWeakCode(old_deps, group, cell);
// Update the list head if necessary.
if (!new_deps.is_identical_to(old_deps)) DependentCode::Set(object, new_deps);
}
Handle<DependentCode> DependentCode::InsertWeakCode(
Handle<DependentCode> entries, DependencyGroup group,
Handle<WeakCell> code_cell) {
......
......@@ -617,21 +617,19 @@ class DependentCode : public FixedArray {
kAllocationSiteTransitionChangedGroup
};
// Register a code dependency of {cell} on {object}.
static void InstallDependency(Isolate* isolate, Handle<WeakCell> cell,
Handle<HeapObject> object,
DependencyGroup group);
bool Contains(DependencyGroup group, WeakCell* code_cell);
bool IsEmpty(DependencyGroup group);
static Handle<DependentCode> InsertWeakCode(Handle<DependentCode> entries,
DependencyGroup group,
Handle<WeakCell> code_cell);
void RemoveCompilationDependencies(DependentCode::DependencyGroup group,
Foreign* info);
void RemoveCompilationDependencies(DependencyGroup group, Foreign* info);
void DeoptimizeDependentCodeGroup(Isolate* isolate,
DependentCode::DependencyGroup group);
void DeoptimizeDependentCodeGroup(Isolate* isolate, DependencyGroup group);
bool MarkCodeForDeoptimization(Isolate* isolate,
DependentCode::DependencyGroup group);
bool MarkCodeForDeoptimization(Isolate* isolate, DependencyGroup group);
// The following low-level accessors are exposed only for tests.
inline DependencyGroup group();
......@@ -642,9 +640,16 @@ class DependentCode : public FixedArray {
private:
static const char* DependencyGroupName(DependencyGroup group);
// Get/Set {object}'s {DependentCode}.
static DependentCode* Get(Handle<HeapObject> object);
static void Set(Handle<HeapObject> object, Handle<DependentCode> dep);
static Handle<DependentCode> New(DependencyGroup group, Handle<Object> object,
Handle<DependentCode> next);
static Handle<DependentCode> EnsureSpace(Handle<DependentCode> entries);
static Handle<DependentCode> InsertWeakCode(Handle<DependentCode> entries,
DependencyGroup group,
Handle<WeakCell> code_cell);
// Compact by removing cleared weak cells and return true if there was
// any cleared weak cell.
......
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