Commit de93b808 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

Revert "[cpu-profiler] Split out debug mode for CPU profiler naming"

This reverts commit fa6ec3cb.

Reason for revert: v8:9169, v8:9170
https://ci.chromium.org/p/v8/builders/ci/V8%20Linux/31457
https://ci.chromium.org/p/v8/builders/ci/V8%20Linux64/31417
https://ci.chromium.org/p/v8/builders/ci/V8%20Win32%20-%20debug/19919

Original change's description:
> [cpu-profiler] Split out debug mode for CPU profiler naming
> 
> Adds a new flag to CpuProfiler to control whether or not "debug" names
> (potentially inferred from scope) are used for captured frames
> associated with a SharedFunctionInfo instance.
> 
> Bug: v8:9135
> Change-Id: I104f3246431dc6336de4e4688c0d98c86e0bb776
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1566169
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Alexei Filippov <alph@chromium.org>
> Reviewed-by: Peter Marshall <petermarshall@chromium.org>
> Commit-Queue: Peter Marshall <petermarshall@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#60972}

TBR=ulan@chromium.org,alph@chromium.org,yangguo@chromium.org,petermarshall@chromium.org,acomminos@fb.com

Change-Id: I573194b5affd31fd0748b9ef3c45052e8ab420f5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:9135
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1581639Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60973}
parent fa6ec3cb
......@@ -297,15 +297,6 @@ enum CpuProfilingMode {
kCallerLineNumbers,
};
// Determines how names are derived for functions sampled.
enum CpuProfilingNamingMode {
// Use the immediate name of functions at compilation time.
kStandardNaming,
// Use more verbose naming for functions without names, inferred from scope
// where possible.
kDebugNaming,
};
/**
* Interface for controlling CPU profiling. Instance of the
* profiler can be created using v8::CpuProfiler::New method.
......@@ -317,8 +308,7 @@ class V8_EXPORT CpuProfiler {
* initialized. The profiler object must be disposed after use by calling
* |Dispose| method.
*/
static CpuProfiler* New(Isolate* isolate,
CpuProfilingNamingMode = kDebugNaming);
static CpuProfiler* New(Isolate* isolate);
/**
* Synchronously collect current stack sample in all profilers attached to
......
......@@ -10117,9 +10117,9 @@ int CpuProfile::GetSamplesCount() const {
return reinterpret_cast<const i::CpuProfile*>(this)->samples_count();
}
CpuProfiler* CpuProfiler::New(Isolate* isolate, CpuProfilingNamingMode mode) {
CpuProfiler* CpuProfiler::New(Isolate* isolate) {
return reinterpret_cast<CpuProfiler*>(
new i::CpuProfiler(reinterpret_cast<i::Isolate*>(isolate), mode));
new i::CpuProfiler(reinterpret_cast<i::Isolate*>(isolate)));
}
void CpuProfiler::Dispose() { delete reinterpret_cast<i::CpuProfiler*>(this); }
......
......@@ -310,16 +310,14 @@ DEFINE_LAZY_LEAKY_OBJECT_GETTER(CpuProfilersManager, GetProfilersManager)
} // namespace
CpuProfiler::CpuProfiler(Isolate* isolate, CpuProfilingNamingMode naming_mode)
: CpuProfiler(isolate, naming_mode, new CpuProfilesCollection(isolate),
nullptr, nullptr) {}
CpuProfiler::CpuProfiler(Isolate* isolate)
: CpuProfiler(isolate, new CpuProfilesCollection(isolate), nullptr,
nullptr) {}
CpuProfiler::CpuProfiler(Isolate* isolate, CpuProfilingNamingMode naming_mode,
CpuProfilesCollection* test_profiles,
CpuProfiler::CpuProfiler(Isolate* isolate, CpuProfilesCollection* test_profiles,
ProfileGenerator* test_generator,
ProfilerEventsProcessor* test_processor)
: isolate_(isolate),
naming_mode_(naming_mode),
sampling_interval_(base::TimeDelta::FromMicroseconds(
FLAG_cpu_profiler_sampling_interval)),
profiles_(test_profiles),
......@@ -411,8 +409,7 @@ void CpuProfiler::StartProcessorIfNotStarted() {
if (profiler_listener_) {
profiler_listener_->set_observer(processor_.get());
} else {
profiler_listener_.reset(
new ProfilerListener(isolate_, processor_.get(), naming_mode_));
profiler_listener_.reset(new ProfilerListener(isolate_, processor_.get()));
}
logger->AddCodeEventListener(profiler_listener_.get());
is_profiling_ = true;
......
......@@ -216,10 +216,10 @@ class V8_EXPORT_PRIVATE SamplingEventsProcessor
class V8_EXPORT_PRIVATE CpuProfiler {
public:
explicit CpuProfiler(Isolate* isolate, CpuProfilingNamingMode = kDebugNaming);
explicit CpuProfiler(Isolate* isolate);
CpuProfiler(Isolate* isolate, CpuProfilingNamingMode naming_mode,
CpuProfilesCollection* profiles, ProfileGenerator* test_generator,
CpuProfiler(Isolate* isolate, CpuProfilesCollection* profiles,
ProfileGenerator* test_generator,
ProfilerEventsProcessor* test_processor);
~CpuProfiler();
......@@ -227,7 +227,6 @@ class V8_EXPORT_PRIVATE CpuProfiler {
static void CollectSample(Isolate* isolate);
typedef v8::CpuProfilingMode ProfilingMode;
typedef v8::CpuProfilingNamingMode NamingMode;
void set_sampling_interval(base::TimeDelta value);
void set_use_precise_sampling(bool);
......@@ -261,7 +260,6 @@ class V8_EXPORT_PRIVATE CpuProfiler {
void CreateEntriesForRuntimeCallStats();
Isolate* const isolate_;
const NamingMode naming_mode_;
base::TimeDelta sampling_interval_;
bool use_precise_sampling_ = true;
std::unique_ptr<CpuProfilesCollection> profiles_;
......
......@@ -21,9 +21,8 @@ namespace v8 {
namespace internal {
ProfilerListener::ProfilerListener(Isolate* isolate,
CodeEventObserver* observer,
CpuProfilingNamingMode naming_mode)
: isolate_(isolate), observer_(observer), naming_mode_(naming_mode) {}
CodeEventObserver* observer)
: isolate_(isolate), observer_(observer) {}
ProfilerListener::~ProfilerListener() = default;
......@@ -164,7 +163,7 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
std::unique_ptr<CodeEntry> inline_entry =
base::make_unique<CodeEntry>(
tag, GetFunctionName(*pos_info.shared), resource_name,
tag, GetName(pos_info.shared->DebugName()), resource_name,
start_pos_info.line + 1, start_pos_info.column + 1, nullptr,
code->InstructionStart(), inline_is_shared_cross_origin);
inline_entry->FillFunctionInfo(*pos_info.shared);
......@@ -183,7 +182,7 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
}
}
rec->entry =
new CodeEntry(tag, GetFunctionName(shared),
new CodeEntry(tag, GetName(shared->DebugName()),
GetName(InferScriptName(script_name, shared)), line, column,
std::move(line_table), abstract_code->InstructionStart(),
is_shared_cross_origin);
......@@ -284,18 +283,6 @@ Name ProfilerListener::InferScriptName(Name name, SharedFunctionInfo info) {
return source_url->IsName() ? Name::cast(source_url) : name;
}
const char* ProfilerListener::GetFunctionName(SharedFunctionInfo shared) {
DisallowHeapAllocation no_gc;
switch (naming_mode_) {
case kDebugNaming:
return GetName(shared.DebugName());
case kStandardNaming:
return GetName(shared.Name());
default:
UNREACHABLE();
}
}
void ProfilerListener::AttachDeoptInlinedFrames(Code code,
CodeDeoptEventRecord* rec) {
int deopt_id = rec->deopt_id;
......
......@@ -8,7 +8,6 @@
#include <memory>
#include <vector>
#include "include/v8-profiler.h"
#include "src/code-events.h"
#include "src/profiler/profile-generator.h"
......@@ -26,8 +25,7 @@ class CodeEventObserver {
class V8_EXPORT_PRIVATE ProfilerListener : public CodeEventListener {
public:
ProfilerListener(Isolate*, CodeEventObserver*,
CpuProfilingNamingMode mode = kDebugNaming);
ProfilerListener(Isolate*, CodeEventObserver*);
~ProfilerListener() override;
void CallbackEvent(Name name, Address entry_point) override;
......@@ -72,8 +70,6 @@ class V8_EXPORT_PRIVATE ProfilerListener : public CodeEventListener {
void set_observer(CodeEventObserver* observer) { observer_ = observer; }
private:
const char* GetFunctionName(SharedFunctionInfo);
void AttachDeoptInlinedFrames(Code code, CodeDeoptEventRecord* rec);
Name InferScriptName(Name name, SharedFunctionInfo info);
V8_INLINE void DispatchCodeEvent(const CodeEventsContainer& evt_rec) {
......@@ -83,7 +79,6 @@ class V8_EXPORT_PRIVATE ProfilerListener : public CodeEventListener {
Isolate* isolate_;
CodeEventObserver* observer_;
StringsStorage function_and_resource_names_;
const CpuProfilingNamingMode naming_mode_;
DISALLOW_COPY_AND_ASSIGN(ProfilerListener);
};
......
......@@ -53,7 +53,7 @@ void TracingCpuProfilerImpl::StartProfiling() {
TRACE_EVENT_CATEGORY_GROUP_ENABLED(
TRACE_DISABLED_BY_DEFAULT("v8.cpu_profiler.hires"), &enabled);
int sampling_interval_us = enabled ? 100 : 1000;
profiler_.reset(new CpuProfiler(isolate_, kDebugNaming));
profiler_.reset(new CpuProfiler(isolate_));
profiler_->set_sampling_interval(
base::TimeDelta::FromMicroseconds(sampling_interval_us));
profiler_->StartProfiling("", true);
......
......@@ -226,7 +226,7 @@ TEST(TickEvents) {
ProfilerEventsProcessor* processor = new SamplingEventsProcessor(
CcTest::i_isolate(), generator,
v8::base::TimeDelta::FromMicroseconds(100), true);
CpuProfiler profiler(isolate, kDebugNaming, profiles, generator, processor);
CpuProfiler profiler(isolate, profiles, generator, processor);
profiles->StartProfiling("", false);
processor->Start();
ProfilerListener profiler_listener(isolate, processor);
......@@ -295,7 +295,7 @@ TEST(Issue1398) {
ProfilerEventsProcessor* processor = new SamplingEventsProcessor(
CcTest::i_isolate(), generator,
v8::base::TimeDelta::FromMicroseconds(100), true);
CpuProfiler profiler(isolate, kDebugNaming, profiles, generator, processor);
CpuProfiler profiler(isolate, profiles, generator, processor);
profiles->StartProfiling("", false);
processor->Start();
ProfilerListener profiler_listener(isolate, processor);
......@@ -1153,7 +1153,7 @@ static void TickLines(bool optimize) {
ProfilerEventsProcessor* processor = new SamplingEventsProcessor(
CcTest::i_isolate(), generator,
v8::base::TimeDelta::FromMicroseconds(100), true);
CpuProfiler profiler(isolate, kDebugNaming, profiles, generator, processor);
CpuProfiler profiler(isolate, profiles, generator, processor);
profiles->StartProfiling("", false);
// TODO(delphick): Stop using the CpuProfiler internals here: This forces
// LogCompiledFunctions so that source positions are collected everywhere.
......@@ -2857,74 +2857,6 @@ TEST(LowPrecisionSamplingStartStopPublic) {
cpu_profiler->Dispose();
}
const char* naming_test_source = R"(
function doWork(n = 1e3) {
let x = 1;
for (let i = 0; i < n; i++) {
for (let j = 0; j < n; j++) {
x += i * j;
}
}
return x;
}
(function testAssignmentPropertyNamedFunction() {
let object = {};
object.propNamed = function () {
doWork();
};
object.propNamed();
})();
)";
TEST(StandardNaming) {
LocalContext env;
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
v8::CpuProfiler* profiler =
v8::CpuProfiler::New(env->GetIsolate(), kStandardNaming);
const auto profile_name = v8_str("");
profiler->StartProfiling(profile_name);
CompileRun(naming_test_source);
auto* profile = profiler->StopProfiling(profile_name);
auto* root = profile->GetTopDownRoot();
auto* toplevel = FindChild(root, "");
DCHECK(toplevel);
auto* prop_assignment_named_test =
GetChild(env.local(), toplevel, "testAssignmentPropertyNamedFunction");
CHECK(FindChild(prop_assignment_named_test, ""));
profiler->Dispose();
}
TEST(DebugNaming) {
LocalContext env;
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
v8::CpuProfiler* profiler =
v8::CpuProfiler::New(env->GetIsolate(), kDebugNaming);
const auto profile_name = v8_str("");
profiler->StartProfiling(profile_name);
CompileRun(naming_test_source);
auto* profile = profiler->StopProfiling(profile_name);
auto* root = profile->GetTopDownRoot();
auto* toplevel = FindChild(root, "");
DCHECK(toplevel);
auto* prop_assignment_named_test =
GetChild(env.local(), toplevel, "testAssignmentPropertyNamedFunction");
CHECK(FindChild(prop_assignment_named_test, "object.propNamed"));
profiler->Dispose();
}
enum class EntryCountMode { kAll, kOnlyInlined };
// Count the number of unique source positions.
......
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