From e7ddb89c535eab5cee947d5dd48c614537d33031 Mon Sep 17 00:00:00 2001 From: Peter Marshall Date: Thu, 19 Dec 2019 14:30:33 +0100 Subject: [PATCH] [cpu-profiler] Handlify ProfilerListener and add no_gc scopes Bug: chromium:1033407 Change-Id: I59642d64fd111884547605f7a010d40e974d2762 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1975752 Reviewed-by: Tobias Tebbi Commit-Queue: Peter Marshall Cr-Commit-Position: refs/heads/master@{#65524} --- src/profiler/profiler-listener.cc | 71 ++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/src/profiler/profiler-listener.cc b/src/profiler/profiler-listener.cc index a2fb6a0b6f..41e211caff 100644 --- a/src/profiler/profiler-listener.cc +++ b/src/profiler/profiler-listener.cc @@ -31,6 +31,7 @@ ProfilerListener::ProfilerListener(Isolate* isolate, ProfilerListener::~ProfilerListener() = default; void ProfilerListener::CallbackEvent(Name name, Address entry_point) { + DisallowHeapAllocation no_gc; CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; rec->instruction_start = entry_point; @@ -41,6 +42,7 @@ void ProfilerListener::CallbackEvent(Name name, Address entry_point) { void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, AbstractCode code, const char* name) { + DisallowHeapAllocation no_gc; CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; rec->instruction_start = code.InstructionStart(); @@ -54,6 +56,7 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, AbstractCode code, Name name) { + DisallowHeapAllocation no_gc; CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; rec->instruction_start = code.InstructionStart(); @@ -69,6 +72,7 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, AbstractCode code, SharedFunctionInfo shared, Name script_name) { + DisallowHeapAllocation no_gc; CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; rec->instruction_start = code.InstructionStart(); @@ -99,43 +103,51 @@ CodeEntry* GetOrInsertCachedEntry( } // namespace void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, - AbstractCode abstract_code, - SharedFunctionInfo shared, - Name script_name, int line, int column) { + AbstractCode abstract_code_unsafe, + SharedFunctionInfo shared_unsafe, + Name script_name_unsafe, int line, + int column) { + HandleScope scope(isolate_); + Handle abstract_code_handle = + handle(abstract_code_unsafe, isolate_); + Handle shared_handle = handle(shared_unsafe, isolate_); + Handle script_name_handle = handle(script_name_unsafe, isolate_); + CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; - rec->instruction_start = abstract_code.InstructionStart(); + rec->instruction_start = abstract_code_handle->InstructionStart(); std::unique_ptr line_table; std::unordered_map> inline_stacks; std::unordered_set, CodeEntry::Hasher, CodeEntry::Equals> cached_inline_entries; bool is_shared_cross_origin = false; - if (shared.script().IsScript()) { - Script script = Script::cast(shared.script()); + if (shared_handle->script().IsScript()) { + Handle