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

[turbofan] Simplify validity check after dependency installation.

The check was accidentally done only when a stress-flag was enabled.
Moreover, the check is actually unnecessary because the code will deopt
itself once it gets run.

Also add a DCHECK that these invalidations can only happen due to
pretenuring changes.

Bug: v8:8520
Change-Id: Ibb008f93e9e417d2f88cd5fd8fd1380db88bbb85
Reviewed-on: https://chromium-review.googlesource.com/c/1384304Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58395}
parent f328613d
...@@ -19,6 +19,10 @@ class CompilationDependencies::Dependency : public ZoneObject { ...@@ -19,6 +19,10 @@ class CompilationDependencies::Dependency : public ZoneObject {
virtual bool IsValid() const = 0; virtual bool IsValid() const = 0;
virtual void PrepareInstall() {} virtual void PrepareInstall() {}
virtual void Install(const MaybeObjectHandle& code) = 0; virtual void Install(const MaybeObjectHandle& code) = 0;
#ifdef DEBUG
virtual bool IsPretenureModeDependency() const { return false; }
#endif
}; };
class InitialMapDependency final : public CompilationDependencies::Dependency { class InitialMapDependency final : public CompilationDependencies::Dependency {
...@@ -146,6 +150,10 @@ class PretenureModeDependency final ...@@ -146,6 +150,10 @@ class PretenureModeDependency final
DependentCode::kAllocationSiteTenuringChangedGroup); DependentCode::kAllocationSiteTenuringChangedGroup);
} }
#ifdef DEBUG
bool IsPretenureModeDependency() const override { return true; }
#endif
private: private:
AllocationSiteRef site_; AllocationSiteRef site_;
PretenureFlag mode_; PretenureFlag mode_;
...@@ -417,15 +425,21 @@ bool CompilationDependencies::Commit(Handle<Code> code) { ...@@ -417,15 +425,21 @@ bool CompilationDependencies::Commit(Handle<Code> code) {
dep->Install(MaybeObjectHandle::Weak(code)); dep->Install(MaybeObjectHandle::Weak(code));
} }
// It is even possible that a GC during the above installations invalidated
// one of the dependencies. However, this should only affect pretenure mode
// dependencies, which we assert below. It is safe to return successfully in
// these cases, because once the code gets executed it will do a stack check
// that triggers its deoptimization.
if (FLAG_stress_gc_during_compilation) { if (FLAG_stress_gc_during_compilation) {
isolate_->heap()->PreciseCollectAllGarbage( isolate_->heap()->PreciseCollectAllGarbage(
Heap::kNoGCFlags, GarbageCollectionReason::kTesting, Heap::kNoGCFlags, GarbageCollectionReason::kTesting,
kGCCallbackFlagForced); kGCCallbackFlagForced);
if (!AreValid()) {
dependencies_.clear();
return false;
}
} }
#ifdef DEBUG
for (auto dep : dependencies_) {
CHECK_IMPLIES(!dep->IsValid(), dep->IsPretenureModeDependency());
}
#endif
dependencies_.clear(); dependencies_.clear();
return true; return true;
......
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