Reviewers: yurys, alph,
Message:
PTAL
Description:
CpuProfiler: public API for deopt info in cpu profiler.
BUG=chromium:452067
LOG=n
Please review this at https://codereview.chromium.org/1045753002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+62, -9 lines):
M include/v8-profiler.h
M src/api.cc
M src/profile-generator.h
M src/profile-generator.cc
M test/cctest/test-cpu-profiler.cc
Index: include/v8-profiler.h
diff --git a/include/v8-profiler.h b/include/v8-profiler.h
index
f9439c2e629445c610b226438a21f82b2687b8de..a7b589dcc40c567df539eb5eb174500a1501116a
100644
--- a/include/v8-profiler.h
+++ b/include/v8-profiler.h
@@ -17,6 +17,20 @@ struct HeapStatsUpdate;
typedef uint32_t SnapshotObjectId;
+
+class V8_EXPORT CpuProfileDeoptInfo {
+ public:
+ struct Frame {
+ int script_id;
+ unsigned int position;
+ };
+
+ const char* GetDeoptReason() const;
+ unsigned GetFramesCount() const;
+ bool GetCallFrames(Frame* frames, unsigned int length) const;
+};
+
+
/**
* CpuProfileNode represents a node in a call graph.
*/
@@ -85,6 +99,11 @@ class V8_EXPORT CpuProfileNode {
/** Retrieves a child node by index. */
const CpuProfileNode* GetChild(int index) const;
+ /** Retrieves a child node by index. */
+ unsigned GetDeoptCount() const;
+
+ const CpuProfileDeoptInfo* GetDeoptInfo(unsigned index) const;
+
static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
};
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
f6398aedf5ea50100398db2b73a20edb5984c9b8..aeef7ba4bf2cb9f95eb57d674b5e9430d65f6604
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -7512,6 +7512,44 @@ const CpuProfileNode* CpuProfileNode::GetChild(int
index) const {
}
+unsigned CpuProfileNode::GetDeoptCount() const {
+ const i::ProfileNode* node = reinterpret_cast<const
i::ProfileNode*>(this);
+ return static_cast<unsigned>(node->deopt_infos().size());
+}
+
+
+const CpuProfileDeoptInfo* CpuProfileNode::GetDeoptInfo(unsigned index)
const {
+ const i::ProfileNode* node = reinterpret_cast<const
i::ProfileNode*>(this);
+ DCHECK_LT(index, node->deopt_infos().size());
+ if (index >= node->deopt_infos().size()) return NULL;
+ const i::DeoptInfo& deopt_info = node->deopt_infos().at(index);
+ return reinterpret_cast<const CpuProfileDeoptInfo*>(&deopt_info);
+}
+
+
+const char* CpuProfileDeoptInfo::GetDeoptReason() const {
+ const i::DeoptInfo* deopt_info = reinterpret_cast<const
i::DeoptInfo*>(this);
+ return deopt_info->deopt_reason;
+}
+
+
+unsigned CpuProfileDeoptInfo::GetFramesCount() const {
+ const i::DeoptInfo* deopt_info = reinterpret_cast<const
i::DeoptInfo*>(this);
+ return static_cast<unsigned>(deopt_info->stack.size());
+}
+
+
+bool CpuProfileDeoptInfo::GetCallFrames(Frame* frames,
+ unsigned int length) const {
+ if (frames == NULL || length == 0) return false;
+ const i::DeoptInfo* deopt_info = reinterpret_cast<const
i::DeoptInfo*>(this);
+ for (size_t i = 0; i < deopt_info->stack.size() && i < length; ++i) {
+ frames[i] = deopt_info->stack[i];
+ }
+ return true;
+}
+
+
void CpuProfile::Delete() {
i::Isolate* isolate = i::Isolate::Current();
i::CpuProfiler* profiler = isolate->cpu_profiler();
Index: src/profile-generator.cc
diff --git a/src/profile-generator.cc b/src/profile-generator.cc
index
385e753025b58c9c91e3798685b13a3a3e97dfa9..9896a414dfe803b66cbd2c655238854f624a6d72
100644
--- a/src/profile-generator.cc
+++ b/src/profile-generator.cc
@@ -119,8 +119,7 @@ DeoptInfo CodeEntry::GetDeoptInfo() {
info.deopt_reason = deopt_reason_;
if (inlined_function_infos_.empty()) {
info.stack.push_back(DeoptInfo::Frame(
- {script_id_,
- static_cast<int>(position_ + deopt_position_.position())}));
+ {script_id_, position_ + deopt_position_.position()}));
return info;
}
// Copy the only branch from the inlining tree where the deopt happened.
@@ -138,7 +137,7 @@ DeoptInfo CodeEntry::GetDeoptInfo() {
InlinedFunctionInfo& inlined_info =
inlined_function_infos_.at(inlining_id);
info.stack.push_back(DeoptInfo::Frame(
{inlined_info.script_id,
- static_cast<int>(inlined_info.start_position + position.raw())}));
+ inlined_info.start_position + position.raw()}));
position = inlined_info.inline_position;
inlining_id = inlined_info.parent_id;
}
Index: src/profile-generator.h
diff --git a/src/profile-generator.h b/src/profile-generator.h
index
e013e29c5db77a1e9852c5a9ef691f789cb96e77..b62318b9212a49ec9be720be3236b10714f7d16c
100644
--- a/src/profile-generator.h
+++ b/src/profile-generator.h
@@ -38,11 +38,8 @@ class JITLineInfoTable : public Malloced {
struct DeoptInfo {
+ typedef v8::CpuProfileDeoptInfo::Frame Frame;
const char* deopt_reason;
- struct Frame {
- int script_id;
- int position;
- };
std::vector<Frame> stack;
};
Index: test/cctest/test-cpu-profiler.cc
diff --git a/test/cctest/test-cpu-profiler.cc
b/test/cctest/test-cpu-profiler.cc
index
a8cbdd505cfe0626de7669c6d952a5cccd8dca52..229dff08e90467563bbd9ed29d6c154aa8916679
100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -56,8 +56,8 @@ static v8::Local<v8::Function> GetFunction(v8::Context*
env, const char* name) {
}
-static int offset(const char* src, const char* substring) {
- return static_cast<int>(strstr(src, substring) - src);
+static unsigned int offset(const char* src, const char* substring) {
+ return static_cast<unsigned int>(strstr(src, substring) - src);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.