Commit 50e50db7 authored by alph's avatar alph Committed by Commit bot

[profiler] Add CodeEvent entries for RCS counters statically on profiler start.

BUG=chromium:665398

Review-Url: https://codereview.chromium.org/2549653002
Cr-Commit-Position: refs/heads/master@{#41462}
parent 0ea4a542
......@@ -323,6 +323,10 @@ const RuntimeCallStats::CounterId RuntimeCallStats::counters[] = {
#undef CALL_BUILTIN_COUNTER
};
// static
const int RuntimeCallStats::counters_count =
arraysize(RuntimeCallStats::counters);
// static
void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer,
CounterId counter_id) {
......
......@@ -837,6 +837,7 @@ class RuntimeCallStats final : public ZoneObject {
#undef CALL_BUILTIN_COUNTER
static const CounterId counters[];
static const int counters_count;
// Starting measuring the time for a function. This will establish the
// connection to the parent counter for properly calculating the own times.
......
......@@ -637,7 +637,16 @@ void CpuProfilesCollection::AddPathToCurrentProfiles(
ProfileGenerator::ProfileGenerator(Isolate* isolate,
CpuProfilesCollection* profiles)
: isolate_(isolate), profiles_(profiles) {}
: isolate_(isolate), profiles_(profiles) {
RuntimeCallStats* rcs = isolate_->counters()->runtime_call_stats();
for (int i = 0; i < RuntimeCallStats::counters_count; ++i) {
RuntimeCallCounter* counter = &(rcs->*(RuntimeCallStats::counters[i]));
DCHECK(counter->name());
auto entry = new CodeEntry(CodeEventListener::FUNCTION_TAG, counter->name(),
CodeEntry::kEmptyNamePrefix, "native V8Runtime");
code_map_.AddCode(reinterpret_cast<Address>(counter), entry, 1);
}
}
void ProfileGenerator::RecordTickSample(const TickSample& sample) {
std::vector<CodeEntry*> entries;
......@@ -742,21 +751,7 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
}
CodeEntry* ProfileGenerator::FindEntry(void* address) {
CodeEntry* entry = code_map_.FindEntry(reinterpret_cast<Address>(address));
if (!entry) {
RuntimeCallStats* rcs = isolate_->counters()->runtime_call_stats();
void* start = reinterpret_cast<void*>(rcs);
void* end = reinterpret_cast<void*>(rcs + 1);
if (start <= address && address < end) {
RuntimeCallCounter* counter =
reinterpret_cast<RuntimeCallCounter*>(address);
CHECK(counter->name());
entry = new CodeEntry(CodeEventListener::FUNCTION_TAG, counter->name(),
CodeEntry::kEmptyNamePrefix, "native V8Runtime");
code_map_.AddCode(reinterpret_cast<Address>(address), entry, 1);
}
}
return entry;
return code_map_.FindEntry(reinterpret_cast<Address>(address));
}
CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) {
......
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