diff --git a/src/profiler/profiler-listener.cc b/src/profiler/profiler-listener.cc index 3b5a69c637..ecb1b952a9 100644 --- a/src/profiler/profiler-listener.cc +++ b/src/profiler/profiler-listener.cc @@ -17,7 +17,8 @@ namespace internal { ProfilerListener::ProfilerListener(Isolate* isolate, CodeEventObserver* observer) - : observer_(observer), + : isolate_(isolate), + observer_(observer), function_and_resource_names_(isolate->heap()->HashSeed()) {} ProfilerListener::~ProfilerListener() = default; @@ -276,6 +277,11 @@ void ProfilerListener::RecordDeoptInlinedFrames(CodeEntry* entry, int deopt_id = static_cast(info->data()); DCHECK(last_position.IsKnown()); std::vector inlined_frames; + + // SourcePosition::InliningStack allocates a handle for the SFI of each + // frame. These don't escape this function, but quickly add up. This + // scope limits their lifetime. + HandleScope scope(isolate_); for (SourcePositionInfo& pos_info : last_position.InliningStack(code)) { if (pos_info.position.ScriptOffset() == kNoSourcePosition) continue; if (!pos_info.function->script()->IsScript()) continue; diff --git a/src/profiler/profiler-listener.h b/src/profiler/profiler-listener.h index 42f98d9cfb..60021fe7b0 100644 --- a/src/profiler/profiler-listener.h +++ b/src/profiler/profiler-listener.h @@ -84,6 +84,7 @@ class ProfilerListener : public CodeEventListener { observer_->CodeEventHandler(evt_rec); } + Isolate* isolate_; CodeEventObserver* observer_; StringsStorage function_and_resource_names_; std::deque> code_entries_;