Commit 09db7cf9 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[codegen] Create PersistentHandles instead of DeferredHandles

As a note, we are not yet passing this to the background so we only
have canonical persistent handles on the main thread.

Bug: v8:7790
Change-Id: I15b264cfacc2d5524a3d13f62574a3576bb7e1a4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2330017
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69176}
parent c60e772c
...@@ -173,17 +173,19 @@ class CompilerTracer : public AllStatic { ...@@ -173,17 +173,19 @@ class CompilerTracer : public AllStatic {
} // namespace } // namespace
// A wrapper around a OptimizedCompilationInfo that detaches the Handles from // A wrapper around a OptimizedCompilationInfo that detaches the Handles from
// the underlying DeferredHandleScope and stores them in info_ on // the underlying PersistentHandlesScope and stores them in info_ on
// destruction. // destruction.
class CompilationHandleScope final { class CompilationHandleScope final {
public: public:
explicit CompilationHandleScope(Isolate* isolate, explicit CompilationHandleScope(Isolate* isolate,
OptimizedCompilationInfo* info) OptimizedCompilationInfo* info)
: deferred_(isolate), info_(info) {} : persistent_(isolate), info_(info) {}
~CompilationHandleScope() { info_->set_deferred_handles(deferred_.Detach()); } ~CompilationHandleScope() {
info_->set_persistent_handles(persistent_.Detach());
}
private: private:
DeferredHandleScope deferred_; PersistentHandlesScope persistent_;
OptimizedCompilationInfo* info_; OptimizedCompilationInfo* info_;
}; };
......
...@@ -136,10 +136,10 @@ OptimizedCompilationInfo::~OptimizedCompilationInfo() { ...@@ -136,10 +136,10 @@ OptimizedCompilationInfo::~OptimizedCompilationInfo() {
} }
} }
void OptimizedCompilationInfo::set_deferred_handles( void OptimizedCompilationInfo::set_persistent_handles(
std::unique_ptr<DeferredHandles> deferred_handles) { std::unique_ptr<PersistentHandles> persistent_handles) {
DCHECK_NULL(deferred_handles_); DCHECK_NULL(persistent_handles_);
deferred_handles_ = std::move(deferred_handles); persistent_handles_ = std::move(persistent_handles);
} }
void OptimizedCompilationInfo::ReopenHandlesInNewHandleScope(Isolate* isolate) { void OptimizedCompilationInfo::ReopenHandlesInNewHandleScope(Isolate* isolate) {
......
...@@ -159,7 +159,8 @@ class V8_EXPORT_PRIVATE OptimizedCompilationInfo final { ...@@ -159,7 +159,8 @@ class V8_EXPORT_PRIVATE OptimizedCompilationInfo final {
osr_frame_ = osr_frame; osr_frame_ = osr_frame;
} }
void set_deferred_handles(std::unique_ptr<DeferredHandles> deferred_handles); void set_persistent_handles(
std::unique_ptr<PersistentHandles> persistent_handles);
void ReopenHandlesInNewHandleScope(Isolate* isolate); void ReopenHandlesInNewHandleScope(Isolate* isolate);
...@@ -263,7 +264,7 @@ class V8_EXPORT_PRIVATE OptimizedCompilationInfo final { ...@@ -263,7 +264,7 @@ class V8_EXPORT_PRIVATE OptimizedCompilationInfo final {
// OptimizedCompilationInfo allocates. // OptimizedCompilationInfo allocates.
Zone* const zone_; Zone* const zone_;
std::unique_ptr<DeferredHandles> deferred_handles_; std::unique_ptr<PersistentHandles> persistent_handles_;
BailoutReason bailout_reason_ = BailoutReason::kNoReason; BailoutReason bailout_reason_ = BailoutReason::kNoReason;
......
...@@ -2958,7 +2958,7 @@ Isolate::Isolate(std::unique_ptr<i::IsolateAllocator> isolate_allocator) ...@@ -2958,7 +2958,7 @@ Isolate::Isolate(std::unique_ptr<i::IsolateAllocator> isolate_allocator)
builtins_(this), builtins_(this),
rail_mode_(PERFORMANCE_ANIMATION), rail_mode_(PERFORMANCE_ANIMATION),
code_event_dispatcher_(new CodeEventDispatcher()), code_event_dispatcher_(new CodeEventDispatcher()),
persistent_handles_list_(new PersistentHandlesList(this)), persistent_handles_list_(new PersistentHandlesList()),
jitless_(FLAG_jitless), jitless_(FLAG_jitless),
#if V8_SFI_HAS_UNIQUE_ID #if V8_SFI_HAS_UNIQUE_ID
next_unique_sfi_id_(0), next_unique_sfi_id_(0),
......
...@@ -121,12 +121,8 @@ void PersistentHandlesList::Remove(PersistentHandles* persistent_handles) { ...@@ -121,12 +121,8 @@ void PersistentHandlesList::Remove(PersistentHandles* persistent_handles) {
persistent_handles_head_ = persistent_handles->next_; persistent_handles_head_ = persistent_handles->next_;
} }
void PersistentHandlesList::Iterate(RootVisitor* visitor) { void PersistentHandlesList::Iterate(RootVisitor* visitor, Isolate* isolate) {
#if DEBUG DCHECK_IMPLIES(FLAG_local_heaps, isolate->heap()->safepoint()->IsActive());
DCHECK(isolate_->heap()->safepoint()->IsActive());
#else
USE(isolate_);
#endif
base::MutexGuard guard(&persistent_handles_mutex_); base::MutexGuard guard(&persistent_handles_mutex_);
for (PersistentHandles* current = persistent_handles_head_; current; for (PersistentHandles* current = persistent_handles_head_; current;
current = current->next_) { current = current->next_) {
......
...@@ -86,20 +86,16 @@ class PersistentHandles { ...@@ -86,20 +86,16 @@ class PersistentHandles {
class PersistentHandlesList { class PersistentHandlesList {
public: public:
explicit PersistentHandlesList(Isolate* isolate) PersistentHandlesList() : persistent_handles_head_(nullptr) {}
: isolate_(isolate), persistent_handles_head_(nullptr) {}
// Iteration is only safe during a safepoint void Iterate(RootVisitor* visitor, Isolate* isolate);
void Iterate(RootVisitor* visitor);
private: private:
void Add(PersistentHandles* persistent_handles); void Add(PersistentHandles* persistent_handles);
void Remove(PersistentHandles* persistent_handles); void Remove(PersistentHandles* persistent_handles);
Isolate* isolate_;
base::Mutex persistent_handles_mutex_; base::Mutex persistent_handles_mutex_;
PersistentHandles* persistent_handles_head_ = nullptr; PersistentHandles* persistent_handles_head_;
friend class PersistentHandles; friend class PersistentHandles;
}; };
......
...@@ -4588,10 +4588,13 @@ void Heap::IterateRoots(RootVisitor* v, base::EnumSet<SkipRoot> options) { ...@@ -4588,10 +4588,13 @@ void Heap::IterateRoots(RootVisitor* v, base::EnumSet<SkipRoot> options) {
if (FLAG_local_heaps) { if (FLAG_local_heaps) {
safepoint_->Iterate(&left_trim_visitor); safepoint_->Iterate(&left_trim_visitor);
safepoint_->Iterate(v); safepoint_->Iterate(v);
isolate_->persistent_handles_list()->Iterate(&left_trim_visitor);
isolate_->persistent_handles_list()->Iterate(v);
} }
isolate_->persistent_handles_list()->Iterate(&left_trim_visitor, isolate_);
isolate_->persistent_handles_list()->Iterate(v, isolate_);
// TODO(solanes): Delete these two iterations once we delete all
// DeferredHandle uses.
isolate_->IterateDeferredHandles(&left_trim_visitor); isolate_->IterateDeferredHandles(&left_trim_visitor);
isolate_->IterateDeferredHandles(v); isolate_->IterateDeferredHandles(v);
v->Synchronize(VisitorSynchronization::kHandleScope); v->Synchronize(VisitorSynchronization::kHandleScope);
......
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