Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(858)

Unified Diff: src/profiler/profile-generator.cc

Issue 2461003002: [profiler] Emit runtime call stats into sampling profile (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/profiler/profile-generator.h ('k') | src/profiler/tick-sample.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/profiler/profile-generator.cc
diff --git a/src/profiler/profile-generator.cc b/src/profiler/profile-generator.cc
index 69a10282becbc21b057fe8f29da516a555e81905..5e9da159586ea64925cf2644a4349620ebbb03b8 100644
--- a/src/profiler/profile-generator.cc
+++ b/src/profiler/profile-generator.cc
@@ -648,8 +648,9 @@ void CpuProfilesCollection::AddPathToCurrentProfiles(
current_profiles_semaphore_.Signal();
}
-ProfileGenerator::ProfileGenerator(CpuProfilesCollection* profiles)
- : profiles_(profiles) {}
+ProfileGenerator::ProfileGenerator(Isolate* isolate,
+ CpuProfilesCollection* profiles)
+ : isolate_(isolate), profiles_(profiles) {}
void ProfileGenerator::RecordTickSample(const TickSample& sample) {
std::vector<CodeEntry*> entries;
@@ -670,16 +671,14 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
// Don't use PC when in external callback code, as it can point
// inside callback's code, and we will erroneously report
// that a callback calls itself.
- entries.push_back(code_map_.FindEntry(
- reinterpret_cast<Address>(sample.external_callback_entry)));
+ entries.push_back(FindEntry(sample.external_callback_entry));
} else {
- CodeEntry* pc_entry =
- code_map_.FindEntry(reinterpret_cast<Address>(sample.pc));
+ CodeEntry* pc_entry = FindEntry(sample.pc);
// If there is no pc_entry we're likely in native code.
// Find out, if top of stack was pointing inside a JS function
// meaning that we have encountered a frameless invocation.
if (!pc_entry && !sample.has_external_callback) {
- pc_entry = code_map_.FindEntry(reinterpret_cast<Address>(sample.tos));
+ pc_entry = FindEntry(sample.tos);
}
// If pc is in the function code before it set up stack frame or after the
// frame was destroyed SafeStackFrameIterator incorrectly thinks that
@@ -712,8 +711,7 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
for (unsigned i = 0; i < sample.frames_count; ++i) {
Address stack_pos = reinterpret_cast<Address>(sample.stack[i]);
- CodeEntry* entry = code_map_.FindEntry(stack_pos);
-
+ CodeEntry* entry = FindEntry(stack_pos);
if (entry) {
// Find out if the entry has an inlining stack associated.
int pc_offset =
@@ -756,6 +754,22 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
sample.update_stats);
}
+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);
+ entry = new CodeEntry(CodeEventListener::FUNCTION_TAG, counter->name,
fmeawad 2016/10/28 19:51:32 I don't think they should be considered as CodeEnt
alph 2016/10/28 20:15:34 I don't think we need an extra class here. CodeEnt
+ CodeEntry::kEmptyNamePrefix, "native V8Runtime");
+ code_map_.AddCode(reinterpret_cast<Address>(address), entry, 1);
+ }
+ }
+ return entry;
+}
CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) {
switch (tag) {
« no previous file with comments | « src/profiler/profile-generator.h ('k') | src/profiler/tick-sample.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698